Empty handlers for closing tags of <bind> and <query> stanzas. We handled those...
[citadel.git] / citadel / sysdep.c
index 42323b163c9350a3048773c95827cef5caaf67b8..19e5eb5ce7a5df1f1b219a801b270426b14e4325 100644 (file)
@@ -405,14 +405,16 @@ int client_write(const char *buf, int nbytes)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", Ctx->ServiceName, Ctx->cs_pid);
                
                fd = fopen(fn, "a+");
-               if (fd)
-               {
-                   fprintf(fd, "Sending: BufSize: %d BufContent: [",
-                           nbytes);
-                   rv = fwrite(buf, nbytes, 1, fd);
-                   fprintf(fd, "]\n");
-                   fclose(fd);
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
                }
+               fprintf(fd, "Sending: BufSize: %d BufContent: [",
+                       nbytes);
+               rv = fwrite(buf, nbytes, 1, fd);
+               fprintf(fd, "]\n");
+               fclose(fd);
        }
 #endif
 //     flush_client_inbuf();
@@ -530,6 +532,11 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
                        
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                fprintf(fd, "Reading BLOB: BufSize: %d ",
                        bytes);
                rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
@@ -546,6 +553,11 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
                
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                fprintf(fd, "Read: %d BufContent: [",
                        StrLength(Target));
                rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
@@ -566,6 +578,11 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
                        
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                fprintf(fd, "Reading BLOB: BufSize: %d ",
                        bytes);
                rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
@@ -591,6 +608,11 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
                
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                fprintf(fd, "Read: %d BufContent: [",
                        StrLength(Target));
                rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
@@ -645,6 +667,11 @@ int client_read_random_blob(StrBuf *Target, int timeout)
                                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
                        
                                fd = fopen(fn, "a+");
+                               if (fd == NULL) {
+                                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                                       cit_backtrace();
+                                       exit(1);
+                               }
                                fprintf(fd, "Read: BufSize: %d BufContent: [",
                                        StrLength(Target));
                                rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
@@ -728,6 +755,11 @@ int CtdlClientGetLine(StrBuf *Target)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
 
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                pch = ChrPtr(CCC->RecvBuf.Buf);
                len = StrLength(CCC->RecvBuf.Buf);
                if (CCC->RecvBuf.ReadWritePointer != NULL)
@@ -781,6 +813,11 @@ int CtdlClientGetLine(StrBuf *Target)
                snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
 
                fd = fopen(fn, "a+");
+               if (fd == NULL) {
+                       syslog(LOG_EMERG, "failed to open file %s: %s", fn, strerror(errno));
+                       cit_backtrace();
+                       exit(1);
+               }
                pch = ChrPtr(CCC->RecvBuf.Buf);
                len = StrLength(CCC->RecvBuf.Buf);
                if (CCC->RecvBuf.ReadWritePointer != NULL)
@@ -1092,7 +1129,7 @@ void checkcrash(void)
  */
 int convert_login(char NameToConvert[]) {
        struct passwd *pw;
-       int a;
+       unsigned int a;
 
        pw = getpwnam(NameToConvert);
        if (pw == NULL) {
@@ -1189,7 +1226,7 @@ void HuntBadSession(void)
 
 }
 
-
+const char *WorkerLogStr = "W";
 /* 
  * This loop just keeps going and going and going...
  */
@@ -1210,6 +1247,8 @@ void *worker_thread(void *blah) {
        ++num_workers;
        pthread_mutex_unlock(&ThreadCountMutex);
 
+       pthread_setspecific(evConKey, WorkerLogStr);
+
        while (!server_shutting_down) {
 
                /* make doubly sure we're not holding any stale db handles