fixed bug where sigint caused the deletion of rule files
authorChristian Thaeter <ct@pipapo.org>
Fri, 14 Mar 2008 08:32:17 +0000 (08:32 +0000)
committerChristian Thaeter <ct@pipapo.org>
Fri, 14 Mar 2008 08:32:17 +0000 (08:32 +0000)
src/rxpd.h
src/rxpd_connection_cmd.c
src/rxpd_file.c

index c3939b0..9ee7b06 100644 (file)
@@ -194,6 +194,9 @@ rxpd_file_new (struct rxpd_base* base, const char* filename);
 void
 rxpd_file_delete (struct rxpd_file* file);
 
+void
+rxpd_file_remove (struct rxpd_file* file);
+
 struct rxpd_file*
 rxpd_file_rules_delete (struct rxpd_file* self);
 
index 474f5b7..eeb86ed 100644 (file)
@@ -304,7 +304,7 @@ rxpd_connection_cmd_DELETE (struct rxpd_connection* self)
 {
   RXPD_FILENAME_REQUIRED;
 
-  rxpd_file_delete (self->file);
+  rxpd_file_remove (self->file);
   rxpd_buffer_printf (&self->out, "#OK:\n");
 }
 
index 017da59..0d74c37 100644 (file)
@@ -65,8 +65,26 @@ rxpd_file_delete (struct rxpd_file* self)
 
       rxpd_file_rules_delete (self);
 
-      while (1) 
+      free ((void*)self->node.key);
+      free (self);
+    }
+}
+
+void
+rxpd_file_remove (struct rxpd_file* self)
+{
+  if (self)
+    {
+      /* psplay remove does not preempt, no locking needed */
+      /* pth_rwlock_acquire (&self->lock, PTH_RWLOCK_RW, FALSE, NULL); */
+      psplay_remove (&self->base->files, &self->node);
+      /* pth_rwlock_release (&self->lock); */
+
+      rxpd_file_rules_delete (self);
+
+      while (1)
         {
+          rxpd_log (self->base, LOG_INFO, "delete file: '%s'\n", (char*)self->node.key);
           remove ((char*)self->node.key);
           char* slash = strrchr ((char*)self->node.key, '/');
           if (slash)