Skip to content

Commit

Permalink
[#189,#59] Some last minute changes completed:
Browse files Browse the repository at this point in the history
1. [#189] Changed openlog() so it call routines get_syslog_flags which fetches the appropriate syslog flags depending on whether /dev/log exists or not
2. [#59] YDB_MAX_TIME name changed to YDB_MAX_TIME_NSEC to reflect nano-second unit of measure.
3. [#59] Fix to sapi-return_subscr_nodes.c which would not have properly reflected INSUFFSUBS when appropriate.
  • Loading branch information
estess authored and nars1 committed Mar 27, 2018
1 parent cd31215 commit 5b1bb44
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 20 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ set_source_list(gtcm_pkdisp gtcm_pkdisp omi_extstr)
set_source_list(gtcm_play gtcm_play dlopen_libyottadb)
set_source_list(gtcm_server gtcm_server dlopen_libyottadb)
set_source_list(gtcm_shmclean gtcm_shmclean dlopen_libyottadb)
set_source_list(gtmsecshr gtmsecshr_wrapper)
set_source_list(gtmsecshr_real gtmsecshr)
set_source_list(gtmsecshr gtmsecshr_wrapper get_syslog_flags)
set_source_list(gtmsecshr_real gtmsecshr get_syslog_flags)
set_source_list(libgtmcrypt gtmcrypt_ref gtmcrypt_pk_ref gtmcrypt_dbk_ref gtmcrypt_sym_ref gtmcrypt_util)
set_source_list(libgtmtls gtm_tls_impl gtmcrypt_util)
set_source_list(libyottadb gtm_main mupip_main mupip_cmd dse_main dse_cmd lke_main lke_cmd)
set_source_list(libyottadb gtcm_play_main omi_srvc_xct omi_extstr)
set_source_list(libyottadb gtcm_server_main gtcm_gnp_server_main gtcm_gnp_clitab gtcm_shmclean_main)
set_source_list(libyottadb dbcertify_main dbcertify_cmd ftok_main)
set_source_list(libyottadb dbcertify_main dbcertify_cmd ftok_main get_syslog_flags)
set_source_list(lke lke dlopen_libyottadb)
set_source_list(maskpass maskpass gtmcrypt_util)
set_source_list(mumps gtm dlopen_libyottadb)
Expand Down
35 changes: 35 additions & 0 deletions sr_unix/get_syslog_flags.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/****************************************************************
* *
* Copyright (c) 2018 YottaDB LLC. and/or its subsidiaries. *
* All rights reserved. *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
* the license, please stop and do not read further. *
* *
****************************************************************/

#include "mdef.h"

#include "gtm_stat.h"
#include "gtm_unistd.h"
#include "gtm_syslog.h"

#include "get_syslog_flags.h"

#define LOGLOCATION "/dev/log"
#define LOGFLAGSWDEVLOG (LOG_PID | LOG_CONS | LOG_NOWAIT)
#define LOGFLAGSWOUTDEVLOG (LOG_PID | LOG_PERROR | LOG_NOWAIT)

/* Routine to check for the existence of /dev/log and if it exists, use LOG_CONS, else use LOG_PERROR */
int get_syslog_flags(void)
{
struct stat buf;
int rc;

rc = stat(LOGLOCATION, &buf);
if (0 == rc)
return LOGFLAGSWDEVLOG;
return LOGFLAGSWOUTDEVLOG;
}
18 changes: 18 additions & 0 deletions sr_unix/get_syslog_flags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/****************************************************************
* *
* Copyright (c) 2018 YottaDB LLC. and/or its subsidiaries. *
* All rights reserved. *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
* the license, please stop and do not read further. *
* *
****************************************************************/

#ifndef _GET_SYSLOG_FLAGS_
#define _GET_SYSLOG_FLAGS_

int get_syslog_flags(void);

#endif
3 changes: 2 additions & 1 deletion sr_unix/gtmsecshr_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
*/
#include "wbox_test_init.h"
#include "gtm_limits.h"
#include "get_syslog_flags.h"

#define ROOTUID 0
#define ROOTGID 0
Expand Down Expand Up @@ -196,7 +197,7 @@ int main()
*/
sigemptyset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL); /* BYPASSOK(sigprocmask) */
OPENLOG("GTMSECSHRINIT", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_USER);
OPENLOG("GTMSECSHRINIT", get_syslog_flags(), LOG_USER);
# ifdef _AIX
# ifdef DEBUG
/* Use some very simplistic processing to obtain values for $gtm_white_box_test_case_enable/number since we are basically
Expand Down
2 changes: 1 addition & 1 deletion sr_unix/libyottadb.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum
#define YDB_MAX_NAMES 35 /* Maximum number of variable names can be specified in a single ydb_*_s() call */
#define YDB_MAX_STR (1 * 1024 * 1024) /* Maximum YottaDB string length */
#define YDB_MAX_SUBS 31 /* Maximum subscripts currently supported */
#define YDB_MAX_TIME (0x7fffffffllu * 1000llu * 1000llu) /* Max specified time in (long long) nanoseconds */
#define YDB_MAX_TIME_NSEC (0x7fffffffllu * 1000llu * 1000llu) /* Max specified time in (long long) nanoseconds */

/* Minimum values */

Expand Down
2 changes: 1 addition & 1 deletion sr_unix/sapi_return_subscr_nodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void sapi_return_subscr_nodes(int *ret_subs_used, ydb_buffer_t *ret_subsarray, c
*ret_subs_used = 0;
for (mstrp = TREF(sapi_query_node_subs), mstrp_top = mstrp + TREF(sapi_query_node_subs_cnt),
outsubp = ret_subsarray, outsubp_top = outsubp + outsubs;
mstrp < mstrp_top;
outsubp < outsubp_top;
mstrp++, outsubp++)
{
if (outsubp_top <= outsubp)
Expand Down
6 changes: 5 additions & 1 deletion sr_unix/util_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
* Copyright (c) 2001-2017 Fidelity National Information *
* Services, Inc. and/or its subsidiaries. All rights reserved. *
* *
* Copyright (c) 2018 YottaDB LLC. and/or its subsidiaries. *
* All rights reserved. *
* *
* This source code contains the intellectual property *
* of its copyright holder(s), and is made available *
* under a license. If you do not know the terms of *
Expand Down Expand Up @@ -45,6 +48,7 @@
#include "gtm_logicals.h"
#include "have_crit.h"
#include "gtm_multi_proc.h"
#include "get_syslog_flags.h"

#ifdef UNICODE_SUPPORTED
#include "gtm_icu_api.h"
Expand Down Expand Up @@ -737,7 +741,7 @@ void util_out_send_oper(char *addr, unsigned int len)
}
}
DEFER_INTERRUPTS(INTRPT_IN_LOG_FUNCTION, prev_intrpt_state);
(void)OPENLOG(facility, LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_USER);
(void)OPENLOG(facility, get_syslog_flags(), LOG_USER);
ENABLE_INTERRUPTS(INTRPT_IN_LOG_FUNCTION, prev_intrpt_state);
}
/* When syslog is processing and a signal occurs, the signal processing might eventually lead to another syslog
Expand Down
3 changes: 2 additions & 1 deletion sr_unix/ydb_fork_n_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "gtm_syslog.h"

#include "libyottadb_int.h"
#include "get_syslog_flags.h"

#define YDBNOTACTIVE "YDB-F-YDBNOTACTIVE The ydb_fork_n_core() facility is not available until the YottaDB runtime " \
"is initialized - Core generation request denied\n"
Expand All @@ -40,7 +41,7 @@ void ydb_fork_n_core(void)
{
if (!gtm_startup_active)
{
openlog("YottaDB/SimpleAPI", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_USER);
OPENLOG("YottaDB/SimpleAPI", get_syslog_flags(), LOG_USER);
syslog(LOG_USER | LOG_INFO, YDBNOTACTIVE);
closelog();
fprintf(stderr, YDBNOTACTIVE); /* TODO - review - echo to stderr as well? Or no? */
Expand Down
4 changes: 2 additions & 2 deletions sr_unix/ydb_hiber_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void ydb_hiber_start(unsigned long long sleep_nsec)
REVERT;
return;
}
if (YDB_MAX_TIME < sleep_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME);
if (YDB_MAX_TIME_NSEC < sleep_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME_NSEC);
timeout_msec = (sleep_nsec / NANOSECS_IN_MSEC);
assert(MAXPOSINT4 > timeout_msec); /* Or else a TIME2LONG error would have been issued above */
timeoutms = (int)timeout_msec;
Expand Down
4 changes: 2 additions & 2 deletions sr_unix/ydb_hiber_start_wait_any.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void ydb_hiber_start_wait_any(unsigned long long sleep_nsec)
REVERT;
return;
}
if (YDB_MAX_TIME < sleep_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME);
if (YDB_MAX_TIME_NSEC < sleep_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME_NSEC);
timeout_msec = (sleep_nsec / NANOSECS_IN_MSEC);
assert(MAXPOSINT4 > timeout_msec); /* Or else a TIME2LONG error would have been issued above */
timeoutms = (int)timeout_msec;
Expand Down
6 changes: 3 additions & 3 deletions sr_unix/ydb_lock_incr_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ int ydb_lock_incr_s(unsigned long long timeout_nsec, ydb_buffer_t *varname, int
/* Check if an outofband action that might care about has popped up */
if (outofband)
outofband_action(FALSE);
assert(MAXPOSINT4 == (YDB_MAX_TIME / NANOSECS_IN_MSEC));
if (YDB_MAX_TIME < timeout_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME);
assert(MAXPOSINT4 == (YDB_MAX_TIME_NSEC / NANOSECS_IN_MSEC));
if (YDB_MAX_TIME_NSEC < timeout_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME_NSEC);
/* Setup and validate the varname */
VALIDATE_VARNAME(varname, var_type, var_svn_index, FALSE);
/* ISV references are not supported for this call */
Expand Down
6 changes: 3 additions & 3 deletions sr_unix/ydb_lock_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ int ydb_lock_s(unsigned long long timeout_nsec, int namecount, ...)
REVERT;
return ((ERR_TPRETRY == SIGNAL) ? YDB_TP_RESTART : -(TREF(ydb_error_code)));
}
assert(MAXPOSINT4 == (YDB_MAX_TIME / NANOSECS_IN_MSEC));
assert(MAXPOSINT4 == (YDB_MAX_TIME_NSEC / NANOSECS_IN_MSEC));
/* Check if an outofband action that might care about has popped up */
if (outofband)
outofband_action(FALSE);
if (YDB_MAX_TIME < timeout_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME);
if (YDB_MAX_TIME_NSEC < timeout_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME_NSEC);
if (0 > namecount)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(4) ERR_INVNAMECOUNT, 2, RTS_ERROR_LITERAL("ydb_lock_s()"));
/* Need to validate all parms before we can do the unlock of all locks held by us */
Expand Down
4 changes: 2 additions & 2 deletions sr_unix/ydb_timer_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void ydb_timer_start(int timer_id, unsigned long long limit_nsec, ydb_funcptr_re
REVERT;
return;
}
if (YDB_MAX_TIME < limit_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME);
if (YDB_MAX_TIME_NSEC < limit_nsec)
rts_error_csa(CSA_ARG(NULL) VARLSTCNT(3) ERR_TIME2LONG, 1, YDB_MAX_TIME_NSEC);
timeout_msec = (limit_nsec / NANOSECS_IN_MSEC);
assert(MAXPOSINT4 > timeout_msec); /* Or else a TIME2LONG error would have been issued above */
timeoutms = (int)timeout_msec;
Expand Down

0 comments on commit 5b1bb44

Please sign in to comment.