From 5fe58065ba978be91eff2a8f758d6b08c998a35c Mon Sep 17 00:00:00 2001 From: patiencew Date: Thu, 22 Nov 2007 03:32:30 +0000 Subject: [PATCH] git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2107 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/ktcp.c | 18 ++++++++++++------ trunk/ceph/kernel/messenger.c | 13 +++++++++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/trunk/ceph/kernel/ktcp.c b/trunk/ceph/kernel/ktcp.c index d6bb68e1391b8..6c38926af1680 100644 --- a/trunk/ceph/kernel/ktcp.c +++ b/trunk/ceph/kernel/ktcp.c @@ -14,10 +14,18 @@ static struct workqueue_struct *send_wq; /* send work queue */ /* Data available on socket or listen socket received a connect */ static void ceph_data_ready(struct sock *sk, int count_unused) { - struct ceph_connection *con = (struct ceph_connection *)sk->sk_user_data; + struct ceph_connection *con; + struct ceph_messenger *msgr; + + printk(KERN_INFO "Entered ceph_data_ready \n"); - printk(KERN_INFO "Entered ceph_data_ready state = %u\n", con->state); - queue_work(recv_wq, &con->rwork); + if (sk->sk_state == TCP_LISTEN) { + msgr = (struct ceph_messenger *)sk->sk_user_data; + queue_work(recv_wq, &msgr->awork); + } else { + con = (struct ceph_connection *)sk->sk_user_data; + queue_work(recv_wq, &con->rwork); + } } /* socket has bufferspace for writing */ @@ -36,10 +44,8 @@ static void ceph_write_space(struct sock *sk) static void ceph_state_change(struct sock *sk) { struct ceph_connection *con = (struct ceph_connection *)sk->sk_user_data; - /* TBD: probably want to set our connection state to OPEN - * if state not set to READ or WRITE pending - */ printk(KERN_INFO "Entered ceph_state_change state = %u\n", con->state); + if (sk->sk_state == TCP_ESTABLISHED) { if (test_and_clear_bit(CONNECTING, &con->state)) set_bit(OPEN, &con->state); diff --git a/trunk/ceph/kernel/messenger.c b/trunk/ceph/kernel/messenger.c index f4fd71d3b5e0f..c34ee8fd7b23f 100644 --- a/trunk/ceph/kernel/messenger.c +++ b/trunk/ceph/kernel/messenger.c @@ -339,7 +339,7 @@ static void try_write(struct work_struct *work) { struct ceph_connection *con; struct ceph_messenger *msgr; - int ret; + int ret = 1; con = container_of(work, struct ceph_connection, swork); msgr = con->msgr; @@ -359,8 +359,10 @@ more: } /* TBD: handle error; return for now */ - if (ret < 0) + if (ret < 0) { + con->error = ret; goto done; /* error */ + } } /* msg pages? */ @@ -380,7 +382,9 @@ more: goto more; } - /* hmm, nothing to do! */ + /* hmm, nothing to do! No more writes pending? */ + if (ret) + clear_bit(WRITE_PEND, &con->state); done: return; } @@ -781,8 +785,9 @@ int ceph_msg_send(struct ceph_messenger *msgr, struct ceph_msg *msg) dout(1, "queuing outgoing message for %s.%d\n", ceph_name_type_str(msg->hdr.dst.name.type), msg->hdr.dst.name.num); ceph_msg_get(msg); + list_add(&con->out_queue, &msg->list_head); - + set_bit(WRITE_PEND, &con->state); spin_unlock(&con->con_lock); put_connection(con); return ret; -- 2.39.5