Commit 077813d7 authored by Wensong Zhang's avatar Wensong Zhang Committed by David S. Miller

[IPVS] retry to run kernel_thread when memory is temporarily exhausted

parent cdcb596b
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment