Commit 2d9873e0 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

sockets: Helper for scheduling conn job

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent b845fa34
...@@ -685,6 +685,27 @@ static void unix_show_job(char *type, int fd, int id) ...@@ -685,6 +685,27 @@ static void unix_show_job(char *type, int fd, int id)
static struct unix_conn_job *conn_jobs; static struct unix_conn_job *conn_jobs;
static int schedule_conn_job(int type, struct unix_sk_entry *ue)
{
struct unix_conn_job *cj;
cj = xmalloc(sizeof(*cj));
if (!cj)
return -1;
cj->type = type;
cj->peer = ue->peer;
cj->fd = ue->fd;
cj->next = conn_jobs;
conn_jobs = cj;
unix_show_job("Sched conn", ue->fd, ue->peer);
return 0;
}
static int run_connect_jobs(void) static int run_connect_jobs(void)
{ {
struct unix_conn_job *cj, *next; struct unix_conn_job *cj, *next;
...@@ -847,27 +868,10 @@ static int open_unix_sk_dgram(int sk, struct unix_sk_entry *ue, int img_fd) ...@@ -847,27 +868,10 @@ static int open_unix_sk_dgram(int sk, struct unix_sk_entry *ue, int img_fd)
SK_HASH_LINK(dgram_bound, d->ino, d); SK_HASH_LINK(dgram_bound, d->ino, d);
} }
if (ue->peer) { if (ue->peer)
if (schedule_conn_job(CJ_DGRAM, ue))
/*
* Connected sockets are a bit compound,
* we might need to defer connect() call
* until peer is alive.
*/
struct unix_conn_job *d;
d = xmalloc(sizeof(*d));
if (!d)
goto err; goto err;
d->type = CJ_DGRAM;
d->peer = ue->peer;
d->fd = ue->fd;
d->next = conn_jobs;
conn_jobs = d;
}
return 0; return 0;
err: err:
return -1; return -1;
...@@ -970,26 +974,9 @@ static int open_unix_sk_stream(int sk, struct unix_sk_entry *ue, int img_fd) ...@@ -970,26 +974,9 @@ static int open_unix_sk_stream(int sk, struct unix_sk_entry *ue, int img_fd)
accept_jobs = aj; accept_jobs = aj;
unix_show_job("Sched acc", ue->fd, ue->id); unix_show_job("Sched acc", ue->fd, ue->id);
} else { } else {
struct unix_conn_job *cj; if (schedule_conn_job((ue->flags & USK_INFLIGHT) ?
CJ_STREAM_INFLIGHT : CJ_STREAM, ue))
/*
* Will do the connect
*/
cj = xmalloc(sizeof(*cj));
if (!cj)
goto err; goto err;
cj->peer = ue->peer;
if (ue->flags & USK_INFLIGHT)
cj->type = CJ_STREAM_INFLIGHT;
else
cj->type = CJ_STREAM;
cj->fd = ue->fd;
cj->next = conn_jobs;
conn_jobs = cj;
unix_show_job("Sched conn", ue->fd, ue->peer);
} }
} else { } else {
pr_err("Unknown state %d\n", ue->state); pr_err("Unknown state %d\n", ue->state);
......
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