#include "housekeeping.h"
#include "tools.h"
#include "modules/crypto/serv_crypto.h" /* Needed for init_ssl, client_write_ssl, client_read_ssl, destruct_ssl */
+#include "ecrash.h"
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
* lprintf() ... Write logging information
*/
void lprintf(enum LogLevel loglevel, const char *format, ...) {
- char *buf;
va_list arg_ptr;
+ char buf[SIZ], buf2[SIZ];
if (enable_syslog) {
va_start(arg_ptr, format);
}
/* stderr output code */
- if (enable_syslog || running_as_daemon) {
- return;
- }
+ if (enable_syslog || running_as_daemon) return;
/* if we run in forground and syslog is disabled, log to terminal */
if (loglevel <= verbosity) {
/* Promote to time_t; types differ on some OSes (like darwin) */
unixtime = tv.tv_sec;
localtime_r(&unixtime, &tim);
-// begin_critical_section(S_LOG);
-
- buf = malloc(SIZ+strlen(format));
-
if (CC->cs_pid != 0) {
sprintf(buf,
"%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] ",
tim.tm_mday, tim.tm_hour, tim.tm_min,
tim.tm_sec, (long)tv.tv_usec);
}
- strcat(buf, format);
- va_start(arg_ptr, buf);
- vfprintf(stderr, buf, arg_ptr);
+ va_start(arg_ptr, format);
+ vsprintf(buf2, format, arg_ptr);
va_end(arg_ptr);
+
+ fprintf(stderr, "%s%s", buf, buf2);
fflush(stderr);
- free (buf);
-// end_critical_section(S_LOG);
}
}
int s;
int i;
int actual_queue_len;
- long ret, ret2;
+
actual_queue_len = queue_len;
if (actual_queue_len < 5) actual_queue_len = 5;
nbytes - bytes_written,
strerror(errno), errno);
cit_backtrace();
+ lprintf(CTDL_DEBUG, "Tried to send: %s", &buf[bytes_written]);
CC->kill_me = 1;
return;
}
CtdlDestroyFixedOutputHooks();
CtdlDestroySessionHooks();
CtdlDestroyServiceHook();
+ eCrash_Uninit();
}
cdb_allocate_tsd();
+ // Register for tracing
+ eCrash_RegisterThread("WorkerThread", 0);
+
while (!time_to_die) {
/* make doubly sure we're not holding any stale db handles
serviceptr->h_command_function;
con->h_async_function =
serviceptr->h_async_function;
-
+ con->ServiceName =
+ serviceptr->ServiceName;
+
/* Determine whether it's a local socket */
if (serviceptr->sockpath != NULL)
con->is_local_socket = 1;
}
if (con != NULL) free (con);//// TODO: could this harm other threads?
/* If control reaches this point, the server is shutting down */
+ eCrash_UnregisterThread();
return(NULL);
}