properly abort if we fail to create debug files instead of crashing.
[citadel.git] / citadel / event_client.c
index 3e2cbdccaadea3eeb711acf13b2e2ceee6551ef1..999c9e4546c1b989efc6fb93c6f6ab8df8394b8f 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "ctdl_module.h"
 #include "event_client.h"
+#include "citserver.h"
 
 ConstStr IOStates[] = {
        {HKEY("DB Queue")},
@@ -562,6 +563,11 @@ IO_send_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                         IO->SendBuf.fd);
 
                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, "Send: BufSize: %ld BufContent: [",
                        nbytes);
                rv = fwrite(pchh, nbytes, 1, fd);
@@ -885,6 +891,11 @@ IO_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents)
                         IO->SendBuf.fd);
 
                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: %ld BufContent: [",
                        nbytes);
                rv = fwrite(pchh, nbytes, 1, fd);