[CRIU] [crtools-bot] sockets: Helper for scheduling conn job
Cyrill Gorcunov
gorcunov at openvz.org
Tue Feb 7 08:27:31 EST 2012
The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
--------------->
commit 2d9873e051efbeb0f279a25a96519a372d541c0d
Author: Pavel Emelyanov <xemul at parallels.com>
Date: Tue Feb 7 15:56:05 2012 +0400
sockets: Helper for scheduling conn job
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
sockets.c | 63 ++++++++++++++++++++++++------------------------------------
1 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/sockets.c b/sockets.c
index 65eb88d..42ca4a5 100644
--- a/sockets.c
+++ b/sockets.c
@@ -685,6 +685,27 @@ static void unix_show_job(char *type, int fd, int id)
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)
{
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)
SK_HASH_LINK(dgram_bound, d->ino, d);
}
- if (ue->peer) {
-
- /*
- * 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)
+ if (ue->peer)
+ if (schedule_conn_job(CJ_DGRAM, ue))
goto err;
- d->type = CJ_DGRAM;
- d->peer = ue->peer;
- d->fd = ue->fd;
- d->next = conn_jobs;
- conn_jobs = d;
- }
-
return 0;
err:
return -1;
@@ -970,26 +974,9 @@ static int open_unix_sk_stream(int sk, struct unix_sk_entry *ue, int img_fd)
accept_jobs = aj;
unix_show_job("Sched acc", ue->fd, ue->id);
} else {
- struct unix_conn_job *cj;
-
- /*
- * Will do the connect
- */
-
- cj = xmalloc(sizeof(*cj));
- if (!cj)
+ if (schedule_conn_job((ue->flags & USK_INFLIGHT) ?
+ CJ_STREAM_INFLIGHT : CJ_STREAM, ue))
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 {
pr_err("Unknown state %d\n", ue->state);
More information about the CRIU
mailing list