diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-10-28 05:09:42 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:04:52 -0500 |
commit | aa19318fd513fb4d6a36793b96fb7ffa66622d6f (patch) | |
tree | 6ec045ea70e727e3c95489a5230d00d36c0b4c9d /source4/smb_server/smb_server.c | |
parent | d668ec53b355de04f45279f14906ab5af116183e (diff) | |
download | samba-aa19318fd513fb4d6a36793b96fb7ffa66622d6f.tar.gz samba-aa19318fd513fb4d6a36793b96fb7ffa66622d6f.tar.bz2 samba-aa19318fd513fb4d6a36793b96fb7ffa66622d6f.zip |
r3307: fixed the send side of the smb_server code to be non-blocking. This
means the whole of the SMB handling code is now non-blocking.
(This used to be commit 30acedb943f0170d30e7b08925280d0dffc7873e)
Diffstat (limited to 'source4/smb_server/smb_server.c')
-rw-r--r-- | source4/smb_server/smb_server.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index 91de20bb31..ff83bfc80c 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -804,8 +804,42 @@ static void smbsrv_recv(struct server_connection *conn, time_t t, uint16_t flags */ static void smbsrv_send(struct server_connection *conn, time_t t, uint16_t flags) { - DEBUG(10,("smbsrv_send\n")); - return; + struct smbsrv_connection *smb_conn = conn->private_data; + + while (smb_conn->pending_send) { + struct smbsrv_request *req = smb_conn->pending_send; + DATA_BLOB blob; + NTSTATUS status; + size_t sendlen; + + blob.data = req->out.buffer; + blob.length = req->out.size; + + /* send as much of this request as we can */ + status = socket_send(conn->socket, &blob, &sendlen, 0); + if (NT_STATUS_IS_ERR(status)) { + smbsrv_terminate_connection(req->smb_conn, nt_errstr(status)); + return; + } + if (sendlen == 0) { + break; + } + + req->out.buffer += sendlen; + req->out.size -= sendlen; + + /* is the whole request gone? */ + if (req->out.size == 0) { + DLIST_REMOVE(smb_conn->pending_send, req); + req_destroy(req); + } + } + + /* if no more requests are pending to be sent then + we should stop select for write */ + if (smb_conn->pending_send == NULL) { + conn->event.fde->flags &= ~EVENT_FD_WRITE; + } } /* @@ -860,11 +894,9 @@ void smbsrv_accept(struct server_connection *conn) DEBUG(5,("smbsrv_accept\n")); - smb_conn = talloc_p(conn, struct smbsrv_connection); + smb_conn = talloc_zero_p(conn, struct smbsrv_connection); if (!smb_conn) return; - ZERO_STRUCTP(smb_conn); - smb_conn->pid = getpid(); sub_set_context(&smb_conn->substitute); |