NETWORKER: add from addresses and new way of setting list headers.
[citadel.git] / citadel / modules / network / serv_network.c
1 /*
2  * This module handles shared rooms, inter-Citadel mail, and outbound
3  * mailing list processing.
4  *
5  * Copyright (c) 2000-2012 by the citadel.org team
6  *
7  *  This program is open source software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License, version 3.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
16  * This is a fairly high-level type of critical section.  It ensures that no
17  * two threads work on the netconfigs files at the same time.  Since we do
18  * so many things inside these, here are the rules:
19  *  1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
20  *  2. Do *not* perform any I/O with the client during these sections.
21  *
22  */
23
24 /*
25  * Duration of time (in seconds) after which pending list subscribe/unsubscribe
26  * requests that have not been confirmed will be deleted.
27  */
28 #define EXP     259200  /* three days */
29
30 #include "sysdep.h"
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <stdio.h>
34 #include <fcntl.h>
35 #include <ctype.h>
36 #include <signal.h>
37 #include <pwd.h>
38 #include <errno.h>
39 #include <sys/stat.h>
40 #include <sys/types.h>
41 #include <dirent.h>
42 #if TIME_WITH_SYS_TIME
43 # include <sys/time.h>
44 # include <time.h>
45 #else
46 # if HAVE_SYS_TIME_H
47 #  include <sys/time.h>
48 # else
49 #  include <time.h>
50 # endif
51 #endif
52 #ifdef HAVE_SYSCALL_H
53 # include <syscall.h>
54 #else 
55 # if HAVE_SYS_SYSCALL_H
56 #  include <sys/syscall.h>
57 # endif
58 #endif
59
60 #include <sys/wait.h>
61 #include <string.h>
62 #include <limits.h>
63 #include <libcitadel.h>
64 #include "citadel.h"
65 #include "server.h"
66 #include "citserver.h"
67 #include "support.h"
68 #include "config.h"
69 #include "user_ops.h"
70 #include "database.h"
71 #include "msgbase.h"
72 #include "internet_addressing.h"
73 #include "serv_network.h"
74 #include "clientsocket.h"
75 #include "file_ops.h"
76 #include "citadel_dirs.h"
77 #include "threads.h"
78 #include "context.h"
79 #include "ctdl_module.h"
80 #include "netspool.h"
81 #include "netmail.h"
82
83 int NetQDebugEnabled = 0;
84 struct CitContext networker_spool_CC;
85
86 /* comes from lookup3.c from libcitadel... */
87 extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
88
89 typedef struct __roomlists {
90         RoomProcList *rplist;
91 }roomlists;
92 /*
93  * When we do network processing, it's accomplished in two passes; one to
94  * gather a list of rooms and one to actually do them.  It's ok that rplist
95  * is global; we have a mutex that keeps it safe.
96  */
97 struct RoomProcList *rplist = NULL;
98
99
100
101 /*
102  * Check the use table.  This is a list of messages which have recently
103  * arrived on the system.  It is maintained and queried to prevent the same
104  * message from being entered into the database multiple times if it happens
105  * to arrive multiple times by accident.
106  */
107 int network_usetable(struct CtdlMessage *msg)
108 {
109         struct CitContext *CCC = CC;
110         char msgid[SIZ];
111         struct cdbdata *cdbut;
112         struct UseTable ut;
113
114         /* Bail out if we can't generate a message ID */
115         if (msg == NULL) {
116                 return(0);
117         }
118         if (msg->cm_fields['I'] == NULL) {
119                 return(0);
120         }
121         if (IsEmptyStr(msg->cm_fields['I'])) {
122                 return(0);
123         }
124
125         /* Generate the message ID */
126         strcpy(msgid, msg->cm_fields['I']);
127         if (haschar(msgid, '@') == 0) {
128                 strcat(msgid, "@");
129                 if (msg->cm_fields['N'] != NULL) {
130                         strcat(msgid, msg->cm_fields['N']);
131                 }
132                 else {
133                         return(0);
134                 }
135         }
136
137         cdbut = cdb_fetch(CDB_USETABLE, msgid, strlen(msgid));
138         if (cdbut != NULL) {
139                 cdb_free(cdbut);
140                 QN_syslog(LOG_DEBUG, "network_usetable() : we already have %s\n", msgid);
141                 return(1);
142         }
143
144         /* If we got to this point, it's unique: add it. */
145         strcpy(ut.ut_msgid, msgid);
146         ut.ut_timestamp = time(NULL);
147         cdb_store(CDB_USETABLE, msgid, strlen(msgid), &ut, sizeof(struct UseTable) );
148         return(0);
149 }
150
151
152 void CalcListID(SpoolControl *sc)
153 {
154         const char *err;
155         int fd;
156         struct CitContext *CCC = CC;
157         char filename[PATH_MAX];
158 #define MAX_LISTIDLENGTH 150
159
160         assoc_file_name(filename, sizeof filename, &sc->room, ctdl_info_dir);
161         fd = open(filename, 0);
162
163         if (fd != 0) {
164                 struct stat stbuf;
165
166                 fstat(fd, &stbuf);
167                 if (stbuf.st_size > 0)
168                 {
169                         sc->RoomInfo = NewStrBufPlain(NULL, stbuf.st_size + 1);
170                         StrBufReadBLOB(sc->RoomInfo, &fd, 0, stbuf.st_size, &err);
171                 }
172                 close(fd);
173         }
174
175         sc->ListID = NewStrBufPlain(NULL, 1024);
176         if (StrLength(sc->RoomInfo) > 0)
177         {
178                 const char *Pos = NULL;
179                 StrBufSipLine(sc->ListID, sc->RoomInfo, &Pos);
180
181                 if (StrLength(sc->ListID) > MAX_LISTIDLENGTH)
182                 {
183                         StrBufCutAt(sc->ListID, MAX_LISTIDLENGTH, NULL);
184                         StrBufAppendBufPlain(sc->ListID, HKEY("..."), 0);
185                 }
186                 StrBufAsciify(sc->ListID, ' ');
187         }
188         else
189         {
190                 StrBufAppendBufPlain(sc->ListID, CCC->room.QRname, -1, 0);
191         }
192
193         StrBufAppendBufPlain(sc->ListID, HKEY("<"), 0);
194
195         if (StrLength(sc->Users[roommailalias]) > 0)
196         {
197                 long Pos;
198                 const char *AtPos;
199
200                 Pos = StrLength(sc->ListID);
201                 StrBufAppendBuf(sc->ListID, sc->Users[roommailalias], 0);
202                 AtPos = strchr(ChrPtr(sc->ListID) + Pos, '@');
203
204                 if (AtPos != NULL)
205                 {
206                         StrBufPeek(sc->ListID, AtPos, 0, '.');
207                 }
208         }
209         else
210         {
211                 StrBufAppendBufPlain(sc->ListID, HKEY("room_"), 0);
212                 StrBufAppendBufPlain(sc->ListID, sc->room.QRname, -1, 0);
213                 StrBufAppendBufPlain(sc->ListID, HKEY("."), 0);
214                 StrBufAppendBufPlain(sc->ListID, config.c_fqdn, -1, 0);
215                 /*
216                  * this used to be:
217                  * roomname <Room-Number.list-id.fqdn>
218                  * according to rfc2919.txt it only has to be a uniq identifier
219                  * under the domain of the system; 
220                  * in general MUAs use it to calculate the reply address nowadays.
221                  */
222         }
223         StrBufAppendBufPlain(sc->ListID, HKEY(">"), 0);
224
225         if (StrLength(sc->Users[roommailalias]) == 0)
226         {
227                 sc->Users[roommailalias] = NewStrBuf();
228                 
229                 StrBufPrintf(sc->Users[roommailalias],
230                              "room_%s@%s",
231                              CCC->room.QRname,
232                              config.c_fqdn);
233
234                 StrBufAsciify(sc->Users[roommailalias], '_');
235                 StrBufLowerCase(sc->Users[roommailalias]);
236         }
237
238 }
239
240 /*
241  * Send the *entire* contents of the current room to one specific network node,
242  * ignoring anything we know about which messages have already undergone
243  * network processing.  This can be used to bring a new node into sync.
244  */
245 int network_sync_to(char *target_node, long len)
246 {
247         struct CitContext *CCC = CC;
248         OneRoomNetCfg OneRNCFG;
249         OneRoomNetCfg *pRNCFG;
250         const RoomNetCfgLine *pCfgLine;
251         SpoolControl sc;
252         int num_spooled = 0;
253
254         /* Grab the configuration line we're looking for */
255         begin_critical_section(S_NETCONFIGS);
256         pRNCFG = CtdlGetNetCfgForRoom(CCC->room.QRnumber);
257         if ((pRNCFG == NULL) ||
258             (pRNCFG->NetConfigs[ignet_push_share] == NULL))
259         {
260                 return -1;
261         }
262
263         pCfgLine = pRNCFG->NetConfigs[ignet_push_share];
264         while (pCfgLine != NULL)
265         {
266                 if (strcmp(ChrPtr(pCfgLine->Value[0]), target_node))
267                         break;
268                 pCfgLine = pCfgLine->next;
269         }
270         if (pCfgLine == NULL)
271         {
272                 return -1;
273         }
274         memset(&sc, 0, sizeof(SpoolControl));
275         memset(&OneRNCFG, 0, sizeof(OneRoomNetCfg));
276         sc.RNCfg = &OneRNCFG;
277         sc.RNCfg->NetConfigs[ignet_push_share] = DuplicateOneGenericCfgLine(pCfgLine);
278
279         end_critical_section(S_NETCONFIGS);
280
281         sc.working_ignetcfg = CtdlLoadIgNetCfg();
282         sc.the_netmap = CtdlReadNetworkMap();
283
284         CalcListID(&sc);
285         /* Send ALL messages */
286         num_spooled = CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL,
287                 network_spool_msg, &sc);
288
289         /* Concise cleanup because we know there's only one node in the sc */
290         DeleteGenericCfgLine(NULL/*TODO*/, &sc.RNCfg->NetConfigs[ignet_push_share]);
291
292         DeleteHash(&sc.working_ignetcfg);
293         DeleteHash(&sc.the_netmap);
294
295         QN_syslog(LOG_NOTICE, "Synchronized %d messages to <%s>\n",
296                   num_spooled, target_node);
297         return(num_spooled);
298 }
299
300
301 /*
302  * Implements the NSYN command
303  */
304 void cmd_nsyn(char *argbuf) {
305         int num_spooled;
306         long len;
307         char target_node[256];
308
309         if (CtdlAccessCheck(ac_aide)) return;
310
311         len = extract_token(target_node, argbuf, 0, '|', sizeof target_node);
312         num_spooled = network_sync_to(target_node, len);
313         if (num_spooled >= 0) {
314                 cprintf("%d Spooled %d messages.\n", CIT_OK, num_spooled);
315         }
316         else {
317                 cprintf("%d No such room/node share exists.\n",
318                         ERROR + ROOM_NOT_FOUND);
319         }
320 }
321
322 RoomProcList *CreateRoomProcListEntry(struct ctdlroom *qrbuf, OneRoomNetCfg *OneRNCFG)
323 {
324         int i;
325         struct RoomProcList *ptr;
326
327         ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList));
328         if (ptr == NULL) return NULL;
329
330         ptr->namelen = strlen(qrbuf->QRname);
331         if (ptr->namelen > ROOMNAMELEN)
332                 ptr->namelen = ROOMNAMELEN - 1;
333
334         memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
335         ptr->name[ptr->namelen] = '\0';
336         ptr->QRNum = qrbuf->QRnumber;
337
338         for (i = 0; i < ptr->namelen; i++)
339         {
340                 ptr->lcname[i] = tolower(ptr->name[i]);
341         }
342
343         ptr->lcname[ptr->namelen] = '\0';
344         ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);
345         ptr->lastsent = OneRNCFG->lastsent;
346         ptr->OneRNCfg = OneRNCFG;
347         return ptr;
348 }
349
350 /*
351  * Batch up and send all outbound traffic from the current room
352  */
353 void network_queue_interesting_rooms(struct ctdlroom *qrbuf, void *data, OneRoomNetCfg *OneRNCfg)
354 {
355         struct RoomProcList *ptr;
356         roomlists *RP = (roomlists*) data;
357
358         if (!HaveSpoolConfig(OneRNCfg))
359                 return;
360
361         ptr = CreateRoomProcListEntry(qrbuf, OneRNCfg);
362
363         if (ptr != NULL)
364         {
365                 ptr->next = RP->rplist;
366                 RP->rplist = ptr;
367         }
368 }
369
370 /*
371  * Batch up and send all outbound traffic from the current room
372  */
373 int network_room_handler (struct ctdlroom *qrbuf)
374 {
375         struct RoomProcList *ptr;
376         OneRoomNetCfg* RNCfg;
377
378         if (qrbuf->QRdefaultview == VIEW_QUEUE)
379                 return 1;
380
381         RNCfg = CtdlGetNetCfgForRoom(qrbuf->QRnumber);
382         if (RNCfg == NULL)
383                 return 1;
384
385         if (!HaveSpoolConfig(RNCfg))
386                 return 1;
387
388         ptr = CreateRoomProcListEntry(qrbuf, RNCfg);
389         if (ptr == NULL)
390                 return 1;
391
392         ptr->OneRNCfg = NULL;
393         begin_critical_section(S_RPLIST);
394         ptr->next = rplist;
395         rplist = ptr;
396         end_critical_section(S_RPLIST);
397         return 1;
398 }
399
400 void destroy_network_queue_room(RoomProcList *rplist)
401 {
402         struct RoomProcList *cur, *p;
403
404         cur = rplist;
405         while (cur != NULL)
406         {
407                 p = cur->next;
408                 free (cur);
409                 cur = p;                
410         }
411 }
412
413 void destroy_network_queue_room_locked (void)
414 {
415         begin_critical_section(S_RPLIST);
416         destroy_network_queue_room(rplist);
417         end_critical_section(S_RPLIST);
418 }
419
420
421
422 /*
423  * Bounce a message back to the sender
424  */
425 void network_bounce(struct CtdlMessage *msg, char *reason)
426 {
427         struct CitContext *CCC = CC;
428         char *oldpath = NULL;
429         char buf[SIZ];
430         char bouncesource[SIZ];
431         char recipient[SIZ];
432         struct recptypes *valid = NULL;
433         char force_room[ROOMNAMELEN];
434         static int serialnum = 0;
435         size_t size;
436
437         QNM_syslog(LOG_DEBUG, "entering network_bounce()\n");
438
439         if (msg == NULL) return;
440
441         snprintf(bouncesource, sizeof bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);
442
443         /* 
444          * Give it a fresh message ID
445          */
446         if (msg->cm_fields['I'] != NULL) {
447                 free(msg->cm_fields['I']);
448         }
449         snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
450                 (long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
451         msg->cm_fields['I'] = strdup(buf);
452
453         /*
454          * FIXME ... right now we're just sending a bounce; we really want to
455          * include the text of the bounced message.
456          */
457         if (msg->cm_fields['M'] != NULL) {
458                 free(msg->cm_fields['M']);
459         }
460         msg->cm_fields['M'] = strdup(reason);
461         msg->cm_format_type = 0;
462
463         /*
464          * Turn the message around
465          */
466         if (msg->cm_fields['R'] == NULL) {
467                 free(msg->cm_fields['R']);
468         }
469
470         if (msg->cm_fields['D'] == NULL) {
471                 free(msg->cm_fields['D']);
472         }
473
474         snprintf(recipient, sizeof recipient, "%s@%s",
475                 msg->cm_fields['A'], msg->cm_fields['N']);
476
477         if (msg->cm_fields['A'] == NULL) {
478                 free(msg->cm_fields['A']);
479         }
480
481         if (msg->cm_fields['N'] == NULL) {
482                 free(msg->cm_fields['N']);
483         }
484
485         if (msg->cm_fields['U'] == NULL) {
486                 free(msg->cm_fields['U']);
487         }
488
489         msg->cm_fields['A'] = strdup(BOUNCESOURCE);
490         msg->cm_fields['N'] = strdup(config.c_nodename);
491         msg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");
492
493         /* prepend our node to the path */
494         if (msg->cm_fields['P'] != NULL) {
495                 oldpath = msg->cm_fields['P'];
496                 msg->cm_fields['P'] = NULL;
497         }
498         else {
499                 oldpath = strdup("unknown_user");
500         }
501         size = strlen(oldpath) + SIZ;
502         msg->cm_fields['P'] = malloc(size);
503         snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
504         free(oldpath);
505
506         /* Now submit the message */
507         valid = validate_recipients(recipient, NULL, 0);
508         if (valid != NULL) if (valid->num_error != 0) {
509                 free_recipients(valid);
510                 valid = NULL;
511         }
512         if ( (valid == NULL) || (!strcasecmp(recipient, bouncesource)) ) {
513                 strcpy(force_room, config.c_aideroom);
514         }
515         else {
516                 strcpy(force_room, "");
517         }
518         if ( (valid == NULL) && IsEmptyStr(force_room) ) {
519                 strcpy(force_room, config.c_aideroom);
520         }
521         CtdlSubmitMsg(msg, valid, force_room, 0);
522
523         /* Clean up */
524         if (valid != NULL) free_recipients(valid);
525         CtdlFreeMessage(msg);
526         QNM_syslog(LOG_DEBUG, "leaving network_bounce()\n");
527 }
528
529
530 void free_network_spoolout_room(SpoolControl *sc)
531 {
532         if (sc != NULL)
533         {
534                 int i;
535                 for (i = subpending; i < maxRoomNetCfg; i++)
536                         FreeStrBuf(&sc->Users[i]);
537                 free(sc);
538         }
539 }
540
541
542
543
544 /*
545  * network_do_queue()
546  * 
547  * Run through the rooms doing various types of network stuff.
548  */
549 void network_do_queue(void)
550 {
551         struct CitContext *CCC = CC;
552         static time_t last_run = 0L;
553         int full_processing = 1;
554         HashList *working_ignetcfg;
555         HashList *the_netmap = NULL;
556         int netmap_changed = 0;
557         roomlists RL;
558         SpoolControl *sc = NULL;
559         SpoolControl *pSC;
560
561         /*
562          * Run the full set of processing tasks no more frequently
563          * than once every n seconds
564          */
565         if ( (time(NULL) - last_run) < config.c_net_freq ) {
566                 full_processing = 0;
567                 syslog(LOG_DEBUG, "Network full processing in %ld seconds.\n",
568                        config.c_net_freq - (time(NULL)- last_run)
569                 );
570         }
571
572         become_session(&networker_spool_CC);
573         begin_critical_section(S_RPLIST);
574         RL.rplist = rplist;
575         rplist = NULL;
576         end_critical_section(S_RPLIST);
577 ///TODO hm, check whether we have a config at all here?
578         /* Load the IGnet Configuration into memory */
579         working_ignetcfg = CtdlLoadIgNetCfg();
580
581         /*
582          * Load the network map and filter list into memory.
583          */
584         if (!server_shutting_down)
585                 the_netmap = CtdlReadNetworkMap();
586 #if 0
587         /* filterlist isn't supported anymore
588         if (!server_shutting_down)
589                 load_network_filter_list();
590         */
591 #endif
592
593         /* 
594          * Go ahead and run the queue
595          */
596         if (full_processing && !server_shutting_down) {
597                 QNM_syslog(LOG_DEBUG, "network: loading outbound queue");
598                 CtdlForEachNetCfgRoom(network_queue_interesting_rooms, &RL, maxRoomNetCfg);
599         }
600
601         if ((RL.rplist != NULL) && (!server_shutting_down)) {
602                 RoomProcList *ptr, *cmp;
603                 ptr = RL.rplist;
604                 QNM_syslog(LOG_DEBUG, "network: running outbound queue");
605                 while (ptr != NULL && !server_shutting_down) {
606                         
607                         cmp = ptr->next;
608                         /* filter duplicates from the list... */
609                         while (cmp != NULL) {
610                                 if ((cmp->namelen > 0) &&
611                                     (cmp->key == ptr->key) &&
612                                     (cmp->namelen == ptr->namelen) &&
613                                     (strcmp(cmp->lcname, ptr->lcname) == 0))
614                                 {
615                                         cmp->namelen = 0;
616                                 }
617                                 cmp = cmp->next;
618                         }
619
620                         if (ptr->namelen > 0) {
621                                 InspectQueuedRoom(&sc,
622                                                   ptr, 
623                                                   working_ignetcfg,
624                                                   the_netmap);
625                         }
626                         ptr = ptr->next;
627                 }
628         }
629
630
631         pSC = sc;
632         while (pSC != NULL)
633         {
634                 network_spoolout_room(pSC);
635                 pSC = pSC->next;
636         }
637
638         pSC = sc;
639         while (pSC != NULL)
640         {
641                 sc = pSC->next;
642                 free_network_spoolout_room(pSC);
643                 pSC = sc;
644         }
645         /* If there is anything in the inbound queue, process it */
646         if (!server_shutting_down) {
647                 network_do_spoolin(working_ignetcfg, 
648                                    the_netmap,
649                                    &netmap_changed);
650         }
651
652         /* Free the filter list in memory */
653         free_netfilter_list();
654
655         /* Save the network map back to disk */
656         if (netmap_changed) {
657                 StrBuf *MapStr = CtdlSerializeNetworkMap(the_netmap);
658                 char *pMapStr = SmashStrBuf(&MapStr);
659                 CtdlPutSysConfig(IGNETMAP, pMapStr);
660                 free(pMapStr);
661         }
662
663         /* combine singe message files into one spool entry per remote node. */
664         network_consolidate_spoolout(working_ignetcfg, the_netmap);
665
666         /* shut down. */
667
668         DeleteHash(&the_netmap);
669
670         DeleteHash(&working_ignetcfg);
671
672         QNM_syslog(LOG_DEBUG, "network: queue run completed");
673
674         if (full_processing) {
675                 last_run = time(NULL);
676         }
677         destroy_network_queue_room(RL.rplist);
678         SaveChangedConfigs();
679
680 }
681
682
683
684
685
686
687
688
689 void network_logout_hook(void)
690 {
691         CitContext *CCC = MyContext();
692
693         /*
694          * If we were talking to a network node, we're not anymore...
695          */
696         if (!IsEmptyStr(CCC->net_node)) {
697                 CtdlNetworkTalkingTo(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
698                 CCC->net_node[0] = '\0';
699         }
700 }
701 void network_cleanup_function(void)
702 {
703         struct CitContext *CCC = CC;
704
705         if (!IsEmptyStr(CCC->net_node)) {
706                 CtdlNetworkTalkingTo(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
707                 CCC->net_node[0] = '\0';
708         }
709 }
710
711
712 /*
713  * Module entry point
714  */
715
716 void SetNetQDebugEnabled(const int n)
717 {
718         NetQDebugEnabled = n;
719 }
720
721 CTDL_MODULE_INIT(network)
722 {
723         if (!threading)
724         {
725                 CtdlFillSystemContext(&networker_spool_CC, "CitNetSpool");
726                 CtdlRegisterDebugFlagHook(HKEY("networkqueue"), SetNetQDebugEnabled, &NetQDebugEnabled);
727                 CtdlRegisterSessionHook(network_cleanup_function, EVT_STOP, PRIO_STOP + 30);
728                 CtdlRegisterSessionHook(network_logout_hook, EVT_LOGOUT, PRIO_LOGOUT + 10);
729                 CtdlRegisterProtoHook(cmd_nsyn, "NSYN", "Synchronize room to node");
730                 CtdlRegisterRoomHook(network_room_handler);
731                 CtdlRegisterCleanupHook(destroy_network_queue_room_locked);
732                 CtdlRegisterSessionHook(network_do_queue, EVT_TIMER, PRIO_QUEUE + 10);
733         }
734         return "network";
735 }