]> code.citadel.org Git - citadel.git/blobdiff - citadel/file_ops.c
* Finished the concurrency check for network polling. (Now works both for
[citadel.git] / citadel / file_ops.c
index d701a443c3d03947bb5651ea84aaa878e7c74a76..a04dc32c9b38ab312e02ba1ef8bb34ba0eb9827c 100644 (file)
 #include "citserver.h"
 
 
+/*
+ * network_talking_to()  --  concurrency checker
+ */
+int network_talking_to(char *nodename, int operation) {
+
+       static char *nttlist = NULL;
+       char *ptr = NULL;
+       int i;
+       char buf[SIZ];
+       int retval = 0;
+
+       begin_critical_section(S_NTTLIST);
+
+       switch(operation) {
+
+               case NTT_ADD:
+                       if (nttlist == NULL) nttlist = strdoop("");
+                       if (nttlist == NULL) break;
+                       nttlist = (char *)reallok(nttlist,
+                               (strlen(nttlist) + strlen(nodename) + 3) );
+                       strcat(nttlist, "|");
+                       strcat(nttlist, nodename);
+                       break;
+
+               case NTT_REMOVE:
+                       if (nttlist == NULL) break;
+                       if (strlen(nttlist) == 0) break;
+                       ptr = mallok(strlen(nttlist));
+                       if (ptr == NULL) break;
+                       strcpy(ptr, "");
+                       for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
+                               extract(buf, nttlist, i);
+                               if ( (strlen(buf) > 0)
+                                    && (strcasecmp(buf, nodename)) ) {
+                                               strcat(ptr, buf);
+                                               strcat(ptr, "|");
+                               }
+                       }
+                       phree(nttlist);
+                       nttlist = ptr;
+                       break;
+
+               case NTT_CHECK:
+                       if (nttlist == NULL) break;
+                       if (strlen(nttlist) == 0) break;
+                       for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
+                               extract(buf, nttlist, i);
+                               if (!strcasecmp(buf, nodename)) ++retval;
+                       }
+                       break;
+       }
+
+       if (nttlist != NULL) lprintf(9, "nttlist=<%s>\n", nttlist);
+       end_critical_section(S_NTTLIST);
+       return(retval);
+}
+
+
+
+
 /*
  * Server command to delete a file from a room's directory
  */
@@ -246,7 +306,7 @@ void cmd_netf(char *cmdbuf)
 
        cprintf("%d File '%s' has been sent to %s.\n", OK, filename,
                destsys);
-       system("nohup ./netproc -i >/dev/null 2>&1 &");
+       /* FIXME start a network run here. */
        return;
 }