X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fnetwork%2Fserv_network.c;h=6c9ed94b95c7625c1656f1b8814ccb8aa02383bf;hb=ce8ccae34638f0a250526db7da80b7ce412eb3a2;hp=aeaab4cad5105184532cdff357415f0febc25d23;hpb=dd2755182e2edca1254c956c10c153841868393a;p=citadel.git diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index aeaab4cad..6c9ed94b9 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -88,7 +88,6 @@ extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval); typedef struct __roomlists { RoomProcList *rplist; - HashList *RoomsInterestedIn; }roomlists; /* * When we do network processing, it's accomplished in two passes; one to @@ -159,24 +158,25 @@ int network_usetable(struct CtdlMessage *msg) int network_sync_to(char *target_node, long len) { struct CitContext *CCC = CC; - const OneRoomNetCfg *OneRNCFG; + OneRoomNetCfg OneRNCFG; + OneRoomNetCfg *pRNCFG; const RoomNetCfgLine *pCfgLine; SpoolControl sc; int num_spooled = 0; /* Grab the configuration line we're looking for */ begin_critical_section(S_NETCONFIGS); - OneRNCFG = CtdlGetNetCfgForRoom(CCC->room.QRnumber); - if ((OneRNCFG == NULL) || - (OneRNCFG->NetConfigs[ignet_push_share] == NULL)) + pRNCFG = CtdlGetNetCfgForRoom(CCC->room.QRnumber); + if ((pRNCFG == NULL) || + (pRNCFG->NetConfigs[ignet_push_share] == NULL)) { return -1; } - pCfgLine = OneRNCFG->NetConfigs[ignet_push_share]; + pCfgLine = pRNCFG->NetConfigs[ignet_push_share]; while (pCfgLine != NULL) { - if (strcmp(ChrPtr(pCfgLine->Value[0]), target_node)) + if (!strcmp(ChrPtr(pCfgLine->Value[0]), target_node)) break; pCfgLine = pCfgLine->next; } @@ -184,9 +184,25 @@ int network_sync_to(char *target_node, long len) { return -1; } - memset(&sc, 0, sizeof(SpoolControl)); - sc.NetConfigs[ignet_push_share] = DuplicateOneGenericCfgLine(pCfgLine); + memset(&sc, 0, sizeof(SpoolControl)); + memset(&OneRNCFG, 0, sizeof(OneRoomNetCfg)); + sc.RNCfg = &OneRNCFG; + sc.RNCfg->NetConfigs[ignet_push_share] = DuplicateOneGenericCfgLine(pCfgLine); + sc.Users[ignet_push_share] = NewStrBufPlain(NULL, + StrLength(pCfgLine->Value[0]) + + StrLength(pCfgLine->Value[1]) + 10); + StrBufAppendBuf(sc.Users[ignet_push_share], + pCfgLine->Value[0], + 0); + StrBufAppendBufPlain(sc.Users[ignet_push_share], + HKEY(","), + 0); + + StrBufAppendBuf(sc.Users[ignet_push_share], + pCfgLine->Value[1], + 0); + CalcListID(&sc); end_critical_section(S_NETCONFIGS); @@ -198,10 +214,11 @@ int network_sync_to(char *target_node, long len) network_spool_msg, &sc); /* Concise cleanup because we know there's only one node in the sc */ - DeleteGenericCfgLine(NULL/*TODO*/, &sc.NetConfigs[ignet_push_share]); + DeleteGenericCfgLine(NULL/*TODO*/, &sc.RNCfg->NetConfigs[ignet_push_share]); DeleteHash(&sc.working_ignetcfg); DeleteHash(&sc.the_netmap); + free_spoolcontrol_struct_members(&sc); QN_syslog(LOG_NOTICE, "Synchronized %d messages to <%s>\n", num_spooled, target_node); @@ -230,7 +247,7 @@ void cmd_nsyn(char *argbuf) { } } -RoomProcList *CreateRoomProcListEntry(struct ctdlroom *qrbuf, const OneRoomNetCfg *OneRNCFG) +RoomProcList *CreateRoomProcListEntry(struct ctdlroom *qrbuf, OneRoomNetCfg *OneRNCFG) { int i; struct RoomProcList *ptr; @@ -253,22 +270,29 @@ RoomProcList *CreateRoomProcListEntry(struct ctdlroom *qrbuf, const OneRoomNetCf ptr->lcname[ptr->namelen] = '\0'; ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345); - ptr->OneRNCFG = OneRNCFG; + ptr->lastsent = OneRNCFG->lastsent; + ptr->OneRNCfg = OneRNCFG; return ptr; } /* * Batch up and send all outbound traffic from the current room */ -void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data, const OneRoomNetCfg *OneRNCfg) +void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data, OneRoomNetCfg *OneRNCfg) { struct RoomProcList *ptr; roomlists *RP = (roomlists*) data; + if (!HaveSpoolConfig(OneRNCfg)) + return; + ptr = CreateRoomProcListEntry(qrbuf, OneRNCfg); - ptr->next = RP->rplist; - RP->rplist = ptr; + if (ptr != NULL) + { + ptr->next = RP->rplist; + RP->rplist = ptr; + } } /* @@ -277,7 +301,7 @@ void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data, const O int network_room_handler (struct ctdlroom *qrbuf) { struct RoomProcList *ptr; - const OneRoomNetCfg* RNCfg; + OneRoomNetCfg* RNCfg; if (qrbuf->QRdefaultview == VIEW_QUEUE) return 1; @@ -286,10 +310,14 @@ int network_room_handler (struct ctdlroom *qrbuf) if (RNCfg == NULL) return 1; + if (!HaveSpoolConfig(RNCfg)) + return 1; + ptr = CreateRoomProcListEntry(qrbuf, RNCfg); if (ptr == NULL) return 1; + ptr->OneRNCfg = NULL; begin_critical_section(S_RPLIST); ptr->next = rplist; rplist = ptr; @@ -428,10 +456,6 @@ void network_bounce(struct CtdlMessage *msg, char *reason) - - - - /* * network_do_queue() * @@ -440,13 +464,14 @@ void network_bounce(struct CtdlMessage *msg, char *reason) void network_do_queue(void) { struct CitContext *CCC = CC; - static int doing_queue = 0; static time_t last_run = 0L; int full_processing = 1; HashList *working_ignetcfg; HashList *the_netmap = NULL; int netmap_changed = 0; roomlists RL; + SpoolControl *sc = NULL; + SpoolControl *pSC; /* * Run the full set of processing tasks no more frequently @@ -459,17 +484,6 @@ void network_do_queue(void) ); } - /* - * This is a simple concurrency check to make sure only one queue run - * is done at a time. We could do this with a mutex, but since we - * don't really require extremely fine granularity here, we'll do it - * with a static variable instead. - */ - if (doing_queue) { - return; - } - doing_queue = 1; - become_session(&networker_spool_CC); begin_critical_section(S_RPLIST); RL.rplist = rplist; @@ -484,8 +498,12 @@ void network_do_queue(void) */ if (!server_shutting_down) the_netmap = CtdlReadNetworkMap(); +#if 0 + /* filterlist isn't supported anymore if (!server_shutting_down) load_network_filter_list(); + */ +#endif /* * Go ahead and run the queue @@ -502,7 +520,7 @@ void network_do_queue(void) while (ptr != NULL && !server_shutting_down) { cmp = ptr->next; - + /* filter duplicates from the list... */ while (cmp != NULL) { if ((cmp->namelen > 0) && (cmp->key == ptr->key) && @@ -515,14 +533,30 @@ void network_do_queue(void) } if (ptr->namelen > 0) { - network_spoolout_room(ptr, - working_ignetcfg, - the_netmap); + InspectQueuedRoom(&sc, + ptr, + working_ignetcfg, + the_netmap); } ptr = ptr->next; } } + + pSC = sc; + while (pSC != NULL) + { + network_spoolout_room(pSC); + pSC = pSC->next; + } + + pSC = sc; + while (pSC != NULL) + { + sc = pSC->next; + free_spoolcontrol_struct(&pSC); + pSC = sc; + } /* If there is anything in the inbound queue, process it */ if (!server_shutting_down) { network_do_spoolin(working_ignetcfg, @@ -536,7 +570,9 @@ void network_do_queue(void) /* Save the network map back to disk */ if (netmap_changed) { StrBuf *MapStr = CtdlSerializeNetworkMap(the_netmap); - CtdlPutSysConfig(IGNETMAP, SmashStrBuf(&MapStr)); + char *pMapStr = SmashStrBuf(&MapStr); + CtdlPutSysConfig(IGNETMAP, pMapStr); + free(pMapStr); } /* combine singe message files into one spool entry per remote node. */ @@ -553,9 +589,9 @@ void network_do_queue(void) if (full_processing) { last_run = time(NULL); } - DeleteHash(&RL.RoomsInterestedIn); destroy_network_queue_room(RL.rplist); - doing_queue = 0; + SaveChangedConfigs(); + }