watchdog: assign potential fd to local var
[trinity.git] / regenerate.c
blob3e9e8dcdccac2f177efd8ab0bb318341701054c5
1 #include <unistd.h>
2 #include "files.h"
3 #include "log.h"
4 #include "maps.h"
5 #include "net.h"
6 #include "params.h"
7 #include "random.h"
8 #include "shm.h"
9 #include "trinity.h"
11 #if 0
12 static void do_sso_sockets(void)
14 struct sockopt so = { 0, 0, 0, 0 };
15 unsigned int i;
17 for (i = 0; i < nr_sockets; i++) {
18 int fd;
20 fd = shm->sockets[i].fd;
21 sso_socket(&shm->sockets[i].triplet, &so, fd);
24 #endif
26 void regenerate(void)
28 if (no_files == TRUE) /* We don't regenerate sockets */
29 return;
31 /* we're about to exit. */
32 if (shm->spawn_no_more)
33 return;
35 shm->regenerating = TRUE;
37 sleep(1); /* give children time to finish with fds. */
39 shm->regenerate = 0;
41 output(0, "Regenerating random pages, fd's etc.\n");
43 regenerate_fds();
45 /* Do random setsockopts on all network sockets. */
46 /* FIXME: Disabled for now.
48 * There's a problem if we have a child doing a read on a socket that blocks
49 * (like some weirdo ax25 socket for eg). The setsockopt will block on it.
51 * I'm not sure what to do about this problem yet.
52 * Maybe try waiting for nr_children to drop to zero when need_regenerate == 1 ?
54 //do_sso_sockets();
56 destroy_shared_mappings();
57 setup_shared_mappings();
59 generate_random_page(page_rand);
61 shm->regenerating = FALSE;