]> code.citadel.org Git - citadel.git/commitdiff
* Began implementing some concurrency stuff for the networker
authorArt Cancro <ajc@citadel.org>
Sat, 6 Oct 2001 20:28:06 +0000 (20:28 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 6 Oct 2001 20:28:06 +0000 (20:28 +0000)
citadel/ChangeLog
citadel/serv_network.c

index 6e0d0a159f9c76cdedd61e3e84e0f0eeda0c938e..32ae52f1dcbcd350fbc1d838f3b1b49052fe7793 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 580.52  2001/10/06 20:28:06  ajc
+ * Began implementing some concurrency stuff for the networker
+
  Revision 580.51  2001/10/06 19:51:47  ajc
  * Stripped the build of obsolete parts of the old networker no longer in use.
 
@@ -2775,3 +2778,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 81dd1aed916875072535e48193a0f9f98693aab7..a92789124361ccc7cf0ce93b21f960e3988c6255 100644 (file)
@@ -89,7 +89,7 @@ struct NetMap *the_netmap = NULL;
 /*
  * network_talking_to()  --  concurrency checker
  */
-int network_talking_to(char *nodename, int oper) {
+int network_talking_to(char *nodename, int operation) {
 
        static char *nttlist = NULL;
        char *ptr = NULL;
@@ -99,11 +99,11 @@ int network_talking_to(char *nodename, int oper) {
 
        begin_critical_section(S_NTTLIST);
 
-       switch(oper) {
+       switch(operation) {
 
                case NTT_ADD:
-                       if (nttlist == NULL) nttlist = stdroop("");
-                       if (nttlist == NULL) return;
+                       if (nttlist == NULL) nttlist = strdoop("");
+                       if (nttlist == NULL) break;
                        nttlist = (char *)reallok(nttlist,
                                (strlen(nttlist) + strlen(nodename) + 3) );
                        strcat(nttlist, "|");
@@ -134,10 +134,11 @@ int network_talking_to(char *nodename, int oper) {
                        for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
                                extract(buf, nttlist, i);
                                if (!strcasecmp(buf, nodename)) ++retval;
+                       }
                        break;
        }
 
-       lprintf(9, "nttlist=<%s>\n", nttlist);
+       if (nttlist != NULL) lprintf(9, "nttlist=<%s>\n", nttlist);
        end_critical_section(S_NTTLIST);
        return(retval);
 }
@@ -1151,11 +1152,14 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
        int sock;
        char buf[SIZ];
 
+       if (network_talking_to(node, NTT_CHECK)) return;
+       network_talking_to(node, NTT_ADD);
        lprintf(5, "Polling node <%s> at %s:%s\n", node, host, port);
 
        sock = sock_connect(host, port, "tcp");
        if (sock < 0) {
                lprintf(7, "Could not connect: %s\n", strerror(errno));
+               network_talking_to(node, NTT_REMOVE);
                return;
        }
        
@@ -1179,6 +1183,7 @@ void network_poll_node(char *node, char *secret, char *host, char *port) {
 
        sock_puts(sock, "QUIT");
 bail:  sock_close(sock);
+       network_talking_to(node, NTT_REMOVE);
 }