]> git.hungrycats.org Git - linux/commitdiff
[IPVS] retry to run kernel_thread when memory is temporarily exhausted
authorWensong Zhang <wensong@linux-vs.org>
Sat, 14 Feb 2004 04:51:56 +0000 (20:51 -0800)
committerDavid S. Miller <davem@nuts.davemloft.net>
Sat, 14 Feb 2004 04:51:56 +0000 (20:51 -0800)
net/ipv4/ipvs/ip_vs_sync.c

index afc5e61ef5b13e4cee7bc00282f454d2064ddbcc..2c1fdca48a3db0bd0238ac445e3688e636013b73 100644 (file)
@@ -618,8 +618,6 @@ ip_vs_receive(struct socket *sock, char *buffer, const size_t buflen)
 }
 
 
-static int errno;
-
 static DECLARE_WAIT_QUEUE_HEAD(sync_wait);
 static pid_t sync_master_pid = 0;
 static pid_t sync_backup_pid = 0;
@@ -766,10 +764,10 @@ static int sync_thread(void *startup)
 
        if (ip_vs_sync_state & IP_VS_STATE_MASTER && !sync_master_pid) {
                state = IP_VS_STATE_MASTER;
-               name = "ipvs syncmaster";
+               name = "ipvs_syncmaster";
        } else if (ip_vs_sync_state & IP_VS_STATE_BACKUP && !sync_backup_pid) {
                state = IP_VS_STATE_BACKUP;
-               name = "ipvs syncbackup";
+               name = "ipvs_syncbackup";
        } else {
                IP_VS_BUG();
                ip_vs_use_count_dec();
@@ -827,10 +825,19 @@ static int sync_thread(void *startup)
 
 static int fork_sync_thread(void *startup)
 {
+       pid_t pid;
+
        /* fork the sync thread here, then the parent process of the
           sync thread is the init process after this thread exits. */
-       if (kernel_thread(sync_thread, startup, 0) < 0)
-               IP_VS_BUG();
+  repeat:
+       if ((pid = kernel_thread(sync_thread, startup, 0)) < 0) {
+               IP_VS_ERR("could not create sync_thread due to %d... "
+                         "retrying.\n", pid);
+               current->state = TASK_UNINTERRUPTIBLE;
+               schedule_timeout(HZ);
+               goto repeat;
+       }
+
        return 0;
 }
 
@@ -857,8 +864,14 @@ int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
                ip_vs_backup_syncid = syncid;
        }
 
-       if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0)
-               IP_VS_BUG();
+  repeat:
+       if ((pid = kernel_thread(fork_sync_thread, &startup, 0)) < 0) {
+               IP_VS_ERR("could not create fork_sync_thread due to %d... "
+                         "retrying.\n", pid);
+               current->state = TASK_UNINTERRUPTIBLE;
+               schedule_timeout(HZ);
+               goto repeat;
+       }
 
        wait_for_completion(&startup);