Module: sems Branch: 1.4 Commit: 00c51f637804e53d2af069b0e19834eee51fec27 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=00c51f637804e53d2af069b0e19834eee51fec27
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Tue May 24 12:24:00 2011 +0200 Added alternative for systems where MSG_NOSIGNAL is not available. --- apps/jsonrpc/RpcPeer.cpp | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/apps/jsonrpc/RpcPeer.cpp b/apps/jsonrpc/RpcPeer.cpp index 22720bb..eb5ad6d 100644 --- a/apps/jsonrpc/RpcPeer.cpp +++ b/apps/jsonrpc/RpcPeer.cpp @@ -112,6 +112,15 @@ int JsonrpcNetstringsConnection::connect(const string& host, int port, res_str = "error setting socket non-blocking"; return 300; } + +#ifndef MSG_NOSIGNAL + int onoff=0; + if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &onoff, sizeof(onoff))) { + res_str = "error in setsockopt: "+string(strerror(errno)); + ::close(fd); + return 300; + } +#endif if (::connect(fd, (const struct sockaddr *)&sa, sizeof(sa)) ==-1 && errno != EINPROGRESS) { @@ -311,7 +320,13 @@ int JsonrpcNetstringsConnection::netstringsBlockingWrite() { rcvd_size = 0; size_t ns_total_len = msg_size+msg_size_s.length()+2; while (rcvd_size != ns_total_len) { - size_t written = send(fd, &ns_begin[rcvd_size], ns_total_len - rcvd_size, MSG_NOSIGNAL); + size_t written = send(fd, &ns_begin[rcvd_size], ns_total_len - rcvd_size, +#ifdef MSG_NOSIGNAL + MSG_NOSIGNAL +#else + 0 +#endif + ); if ((written<0 && (errno==EAGAIN || errno==EWOULDBLOCK)) || written==0) { usleep(SEND_SLEEP); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
