blob: cc81390fd2cddca2b16568feb4845e6d03ab07f9 [file] [log] [blame]
Mark Slee9f0c6512007-02-28 23:58:26 +00001// Copyright (c) 2006- Facebook
2// Distributed under the Thrift Software License
3//
4// See accompanying file LICENSE or visit the Thrift site at:
5// http://developers.facebook.com/thrift/
6
Mark Sleee8540632006-05-30 09:24:40 +00007#include <sys/socket.h>
David Reiss1677ac92008-04-08 06:26:27 +00008#include <sys/poll.h>
Mark Sleedd564972007-08-21 02:39:57 +00009#include <sys/types.h>
Mark Sleee8540632006-05-30 09:24:40 +000010#include <netinet/in.h>
Mark Slee29050782006-09-29 00:12:30 +000011#include <netinet/tcp.h>
Mark Slee6d56eb92007-07-06 22:28:15 +000012#include <netdb.h>
Mark Sleea5a783f2007-03-02 19:41:08 +000013#include <fcntl.h>
Mark Slee8d7e1f62006-06-07 06:48:56 +000014#include <errno.h>
Mark Sleee8540632006-05-30 09:24:40 +000015
Marc Slemkod42a2c22006-08-10 03:30:18 +000016#include "TSocket.h"
17#include "TServerSocket.h"
Marc Slemko16698852006-08-04 03:16:10 +000018#include <boost/shared_ptr.hpp>
Mark Sleee8540632006-05-30 09:24:40 +000019
Mark Slee256bdc42007-11-27 08:42:19 +000020namespace facebook { namespace thrift { namespace transport {
Marc Slemko6f038a72006-08-03 18:58:09 +000021
Martin Kraemere6c4fa62007-07-09 19:08:25 +000022using namespace std;
David Reissd4a269c2007-08-23 02:37:19 +000023using boost::shared_ptr;
Marc Slemko16698852006-08-04 03:16:10 +000024
Mark Sleee8540632006-05-30 09:24:40 +000025TServerSocket::TServerSocket(int port) :
Mark Slee29050782006-09-29 00:12:30 +000026 port_(port),
Martin Kraemeree341cb2007-02-05 21:40:38 +000027 serverSocket_(-1),
Mark Slee29050782006-09-29 00:12:30 +000028 acceptBacklog_(1024),
29 sendTimeout_(0),
Mark Sleea5a783f2007-03-02 19:41:08 +000030 recvTimeout_(0),
boz1ea81ce2007-05-14 23:04:33 +000031 retryLimit_(0),
32 retryDelay_(0),
Christopher Piro9cc63b52008-03-21 00:40:42 +000033 tcpSendBuffer_(0),
34 tcpRecvBuffer_(0),
Mark Slee561b5362007-03-09 19:26:29 +000035 intSock1_(-1),
36 intSock2_(-1) {}
Mark Slee29050782006-09-29 00:12:30 +000037
38TServerSocket::TServerSocket(int port, int sendTimeout, int recvTimeout) :
39 port_(port),
Martin Kraemeree341cb2007-02-05 21:40:38 +000040 serverSocket_(-1),
Mark Slee29050782006-09-29 00:12:30 +000041 acceptBacklog_(1024),
42 sendTimeout_(sendTimeout),
Mark Sleea5a783f2007-03-02 19:41:08 +000043 recvTimeout_(recvTimeout),
boz1ea81ce2007-05-14 23:04:33 +000044 retryLimit_(0),
45 retryDelay_(0),
Christopher Piro9cc63b52008-03-21 00:40:42 +000046 tcpSendBuffer_(0),
47 tcpRecvBuffer_(0),
Mark Slee561b5362007-03-09 19:26:29 +000048 intSock1_(-1),
49 intSock2_(-1) {}
Mark Sleee8540632006-05-30 09:24:40 +000050
51TServerSocket::~TServerSocket() {
52 close();
53}
54
Mark Slee29050782006-09-29 00:12:30 +000055void TServerSocket::setSendTimeout(int sendTimeout) {
56 sendTimeout_ = sendTimeout;
57}
58
59void TServerSocket::setRecvTimeout(int recvTimeout) {
60 recvTimeout_ = recvTimeout;
61}
62
boz1ea81ce2007-05-14 23:04:33 +000063void TServerSocket::setRetryLimit(int retryLimit) {
64 retryLimit_ = retryLimit;
65}
66
67void TServerSocket::setRetryDelay(int retryDelay) {
68 retryDelay_ = retryDelay;
69}
70
Christopher Piro9cc63b52008-03-21 00:40:42 +000071void TServerSocket::setTcpSendBuffer(int tcpSendBuffer) {
72 tcpSendBuffer_ = tcpSendBuffer;
73}
74
75void TServerSocket::setTcpRecvBuffer(int tcpRecvBuffer) {
76 tcpRecvBuffer_ = tcpRecvBuffer;
77}
78
Mark Slee8d7e1f62006-06-07 06:48:56 +000079void TServerSocket::listen() {
Mark Slee561b5362007-03-09 19:26:29 +000080 int sv[2];
81 if (-1 == socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) {
David Reiss9b209552008-04-08 06:26:05 +000082 int errno_copy = errno;
83 string errStr = "TServerSocket::listen() socketpair() " + TOutput::strerror_s(errno_copy);
84 GlobalOutput(errStr.c_str());
Mark Slee561b5362007-03-09 19:26:29 +000085 intSock1_ = -1;
86 intSock2_ = -1;
87 } else {
Mark Sleee02385b2007-06-09 01:21:16 +000088 intSock1_ = sv[1];
89 intSock2_ = sv[0];
Mark Slee561b5362007-03-09 19:26:29 +000090 }
91
Mark Slee6d56eb92007-07-06 22:28:15 +000092 struct addrinfo hints, *res, *res0;
93 int error;
94 char port[sizeof("65536") + 1];
95 memset(&hints, 0, sizeof(hints));
96 hints.ai_family = PF_UNSPEC;
97 hints.ai_socktype = SOCK_STREAM;
Mark Slee256bdc42007-11-27 08:42:19 +000098 hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
Mark Slee6d56eb92007-07-06 22:28:15 +000099 sprintf(port, "%d", port_);
100
101 // Wildcard address
102 error = getaddrinfo(NULL, port, &hints, &res0);
103 if (error) {
104 fprintf(stderr, "getaddrinfo %d: %s\n", error, gai_strerror(error));
105 close();
106 throw TTransportException(TTransportException::NOT_OPEN, "Could not resolve host for server socket.");
107 }
108
109 // Pick the ipv6 address first since ipv4 addresses can be mapped
110 // into ipv6 space.
111 for (res = res0; res; res = res->ai_next) {
112 if (res->ai_family == AF_INET6 || res->ai_next == NULL)
113 break;
114 }
Mark Slee256bdc42007-11-27 08:42:19 +0000115
Mark Slee6d56eb92007-07-06 22:28:15 +0000116 serverSocket_ = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
Mark Sleee8540632006-05-30 09:24:40 +0000117 if (serverSocket_ == -1) {
David Reiss9b209552008-04-08 06:26:05 +0000118 int errno_copy = errno;
119 string errStr = "TServerSocket::listen() socket() " + TOutput::strerror_s(errno_copy);
120 GlobalOutput(errStr.c_str());
Mark Sleee8540632006-05-30 09:24:40 +0000121 close();
David Reiss9b209552008-04-08 06:26:05 +0000122 throw TTransportException(TTransportException::NOT_OPEN, "Could not create server socket.", errno_copy);
Mark Sleee8540632006-05-30 09:24:40 +0000123 }
124
125 // Set reusaddress to prevent 2MSL delay on accept
126 int one = 1;
127 if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_REUSEADDR,
128 &one, sizeof(one))) {
David Reiss9b209552008-04-08 06:26:05 +0000129 int errno_copy = errno;
130 string errStr = "TServerSocket::listen() setsockopt() SO_REUSEADDR " + TOutput::strerror_s(errno_copy);
131 GlobalOutput(errStr.c_str());
Mark Sleee8540632006-05-30 09:24:40 +0000132 close();
David Reiss9b209552008-04-08 06:26:05 +0000133 throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_REUSEADDR", errno_copy);
Mark Sleee8540632006-05-30 09:24:40 +0000134 }
135
Christopher Piro9cc63b52008-03-21 00:40:42 +0000136 // Set TCP buffer sizes
137 if (tcpSendBuffer_ > 0) {
138 if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_SNDBUF,
139 &tcpSendBuffer_, sizeof(tcpSendBuffer_))) {
David Reiss9b209552008-04-08 06:26:05 +0000140 int errno_copy = errno;
141 string errStr = "TServerSocket::listen() setsockopt() SO_SNDBUF " + TOutput::strerror_s(errno_copy);
142 GlobalOutput(errStr.c_str());
Christopher Piro9cc63b52008-03-21 00:40:42 +0000143 close();
David Reiss9b209552008-04-08 06:26:05 +0000144 throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_SNDBUF", errno_copy);
Christopher Piro9cc63b52008-03-21 00:40:42 +0000145 }
146 }
147
148 if (tcpRecvBuffer_ > 0) {
149 if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_RCVBUF,
150 &tcpRecvBuffer_, sizeof(tcpRecvBuffer_))) {
David Reiss9b209552008-04-08 06:26:05 +0000151 int errno_copy = errno;
152 string errStr = "TServerSocket::listen() setsockopt() SO_RCVBUF " + TOutput::strerror_s(errno_copy);
153 GlobalOutput(errStr.c_str());
Christopher Piro9cc63b52008-03-21 00:40:42 +0000154 close();
David Reiss9b209552008-04-08 06:26:05 +0000155 throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_RCVBUF", errno_copy);
Christopher Piro9cc63b52008-03-21 00:40:42 +0000156 }
157 }
158
Mark Slee29050782006-09-29 00:12:30 +0000159 // Defer accept
160 #ifdef TCP_DEFER_ACCEPT
161 if (-1 == setsockopt(serverSocket_, SOL_SOCKET, TCP_DEFER_ACCEPT,
162 &one, sizeof(one))) {
David Reiss9b209552008-04-08 06:26:05 +0000163 int errno_copy = errno;
164 string errStr = "TServerSocket::listen() setsockopt() TCP_DEFER_ACCEPT " + TOutput::strerror_s(errno_copy);
165 GlobalOutput(errStr.c_str());
Mark Slee29050782006-09-29 00:12:30 +0000166 close();
David Reiss9b209552008-04-08 06:26:05 +0000167 throw TTransportException(TTransportException::NOT_OPEN, "Could not set TCP_DEFER_ACCEPT", errno_copy);
Mark Slee29050782006-09-29 00:12:30 +0000168 }
169 #endif // #ifdef TCP_DEFER_ACCEPT
170
Mark Sleee8540632006-05-30 09:24:40 +0000171 // Turn linger off, don't want to block on calls to close
172 struct linger ling = {0, 0};
173 if (-1 == setsockopt(serverSocket_, SOL_SOCKET, SO_LINGER,
174 &ling, sizeof(ling))) {
David Reiss9b209552008-04-08 06:26:05 +0000175 int errno_copy = errno;
176 string errStr = "TServerSocket::listen() setsockopt() SO_LINGER " + TOutput::strerror_s(errno_copy);
177 GlobalOutput(errStr.c_str());
Mark Sleee8540632006-05-30 09:24:40 +0000178 close();
David Reiss9b209552008-04-08 06:26:05 +0000179 throw TTransportException(TTransportException::NOT_OPEN, "Could not set SO_LINGER", errno_copy);
Mark Sleee8540632006-05-30 09:24:40 +0000180 }
181
Mark Slee29050782006-09-29 00:12:30 +0000182 // TCP Nodelay, speed over bandwidth
183 if (-1 == setsockopt(serverSocket_, IPPROTO_TCP, TCP_NODELAY,
184 &one, sizeof(one))) {
David Reiss9b209552008-04-08 06:26:05 +0000185 int errno_copy = errno;
186 string errStr = "TServerSocket::listen() setsockopt() TCP_NODELAY " + TOutput::strerror_s(errno_copy);
187 GlobalOutput(errStr.c_str());
Mark Slee29050782006-09-29 00:12:30 +0000188 close();
David Reiss9b209552008-04-08 06:26:05 +0000189 throw TTransportException(TTransportException::NOT_OPEN, "Could not set TCP_NODELAY", errno_copy);
Mark Slee29050782006-09-29 00:12:30 +0000190 }
191
Mark Sleea5a783f2007-03-02 19:41:08 +0000192 // Set NONBLOCK on the accept socket
193 int flags = fcntl(serverSocket_, F_GETFL, 0);
194 if (flags == -1) {
David Reiss9b209552008-04-08 06:26:05 +0000195 int errno_copy = errno;
196 string errStr = "TServerSocket::listen() fcntl() F_GETFL " + TOutput::strerror_s(errno_copy);
197 GlobalOutput(errStr.c_str());
198 throw TTransportException(TTransportException::NOT_OPEN, "fcntl() failed", errno_copy);
Mark Sleea5a783f2007-03-02 19:41:08 +0000199 }
Mark Slee561b5362007-03-09 19:26:29 +0000200
Mark Sleea5a783f2007-03-02 19:41:08 +0000201 if (-1 == fcntl(serverSocket_, F_SETFL, flags | O_NONBLOCK)) {
David Reiss9b209552008-04-08 06:26:05 +0000202 int errno_copy = errno;
203 string errStr = "TServerSocket::listen() fcntl() O_NONBLOCK " + TOutput::strerror_s(errno_copy);
204 GlobalOutput(errStr.c_str());
205 throw TTransportException(TTransportException::NOT_OPEN, "fcntl() failed", errno_copy);
Mark Sleea5a783f2007-03-02 19:41:08 +0000206 }
207
boz1ea81ce2007-05-14 23:04:33 +0000208 // prepare the port information
Mark Slee256bdc42007-11-27 08:42:19 +0000209 // we may want to try to bind more than once, since SO_REUSEADDR doesn't
boz1ea81ce2007-05-14 23:04:33 +0000210 // always seem to work. The client can configure the retry variables.
211 int retries = 0;
212 do {
Mark Slee6d56eb92007-07-06 22:28:15 +0000213 if (0 == bind(serverSocket_, res->ai_addr, res->ai_addrlen)) {
boz1ea81ce2007-05-14 23:04:33 +0000214 break;
215 }
216
217 // use short circuit evaluation here to only sleep if we need to
218 } while ((retries++ < retryLimit_) && (sleep(retryDelay_) == 0));
219
Mark Slee6d56eb92007-07-06 22:28:15 +0000220 // free addrinfo
221 freeaddrinfo(res0);
Mark Slee256bdc42007-11-27 08:42:19 +0000222
boz1ea81ce2007-05-14 23:04:33 +0000223 // throw an error if we failed to bind properly
224 if (retries > retryLimit_) {
Mark Sleee8540632006-05-30 09:24:40 +0000225 char errbuf[1024];
226 sprintf(errbuf, "TServerSocket::listen() BIND %d", port_);
boz6ded7752007-06-05 22:41:18 +0000227 GlobalOutput(errbuf);
Mark Sleee8540632006-05-30 09:24:40 +0000228 close();
Mark Sleef9831082007-02-20 20:59:21 +0000229 throw TTransportException(TTransportException::NOT_OPEN, "Could not bind");
Mark Sleee8540632006-05-30 09:24:40 +0000230 }
231
232 // Call listen
233 if (-1 == ::listen(serverSocket_, acceptBacklog_)) {
David Reiss9b209552008-04-08 06:26:05 +0000234 int errno_copy = errno;
235 string errStr = "TServerSocket::listen() listen() " + TOutput::strerror_s(errno_copy);
236 GlobalOutput(errStr.c_str());
Mark Sleee8540632006-05-30 09:24:40 +0000237 close();
David Reiss9b209552008-04-08 06:26:05 +0000238 throw TTransportException(TTransportException::NOT_OPEN, "Could not listen", errno_copy);
Mark Sleee8540632006-05-30 09:24:40 +0000239 }
240
241 // The socket is now listening!
Mark Sleee8540632006-05-30 09:24:40 +0000242}
243
Marc Slemko16698852006-08-04 03:16:10 +0000244shared_ptr<TTransport> TServerSocket::acceptImpl() {
Martin Kraemer10640d82007-02-03 01:59:12 +0000245 if (serverSocket_ < 0) {
Mark Sleef9831082007-02-20 20:59:21 +0000246 throw TTransportException(TTransportException::NOT_OPEN, "TServerSocket not listening");
Mark Sleee8540632006-05-30 09:24:40 +0000247 }
248
David Reiss1677ac92008-04-08 06:26:27 +0000249 struct pollfd fds[2];
Mark Sleea5a783f2007-03-02 19:41:08 +0000250
Aditya Agarwal7859a572007-05-31 01:33:07 +0000251 int maxEintrs = 5;
252 int numEintrs = 0;
253
Mark Sleea5a783f2007-03-02 19:41:08 +0000254 while (true) {
David Reiss1677ac92008-04-08 06:26:27 +0000255 memset(fds, 0 , sizeof(fds));
256 fds[0].fd = serverSocket_;
257 fds[0].events = POLLIN;
Mark Slee561b5362007-03-09 19:26:29 +0000258 if (intSock2_ >= 0) {
David Reiss1677ac92008-04-08 06:26:27 +0000259 fds[1].fd = intSock2_;
David Reiss2724c7a2008-04-18 17:48:03 +0000260 fds[1].events = POLLIN;
Mark Sleea5a783f2007-03-02 19:41:08 +0000261 }
David Reiss1677ac92008-04-08 06:26:27 +0000262 int ret = poll(fds, 2, -1);
Mark Sleea5a783f2007-03-02 19:41:08 +0000263
Mark Slee561b5362007-03-09 19:26:29 +0000264 if (ret < 0) {
Aditya Agarwal7859a572007-05-31 01:33:07 +0000265 // error cases
bozf83c9db2007-05-31 23:38:37 +0000266 if (errno == EINTR && (numEintrs++ < maxEintrs)) {
Mark Slee256bdc42007-11-27 08:42:19 +0000267 // EINTR needs to be handled manually and we can tolerate
Aditya Agarwal7859a572007-05-31 01:33:07 +0000268 // a certain number
269 continue;
270 }
David Reiss9b209552008-04-08 06:26:05 +0000271 int errno_copy = errno;
272 string errStr = "TServerSocket::acceptImpl() poll() " + TOutput::strerror_s(errno_copy);
273 GlobalOutput(errStr.c_str());
274 throw TTransportException(TTransportException::UNKNOWN, "Unknown", errno_copy);
Mark Slee561b5362007-03-09 19:26:29 +0000275 } else if (ret > 0) {
276 // Check for an interrupt signal
David Reiss1677ac92008-04-08 06:26:27 +0000277 if (intSock2_ >= 0 && (fds[1].revents & POLLIN)) {
Mark Slee561b5362007-03-09 19:26:29 +0000278 int8_t buf;
279 if (-1 == recv(intSock2_, &buf, sizeof(int8_t), 0)) {
David Reiss9b209552008-04-08 06:26:05 +0000280 int errno_copy = errno;
281 string errStr = "TServerSocket::acceptImpl() recv() interrupt " + TOutput::strerror_s(errno_copy);
282 GlobalOutput(errStr.c_str());
Mark Slee561b5362007-03-09 19:26:29 +0000283 }
284 throw TTransportException(TTransportException::INTERRUPTED);
285 }
David Reiss9b209552008-04-08 06:26:05 +0000286
Mark Slee561b5362007-03-09 19:26:29 +0000287 // Check for the actual server socket being ready
David Reiss1677ac92008-04-08 06:26:27 +0000288 if (fds[0].revents & POLLIN) {
Mark Slee561b5362007-03-09 19:26:29 +0000289 break;
290 }
291 } else {
David Reiss1677ac92008-04-08 06:26:27 +0000292 GlobalOutput("TServerSocket::acceptImpl() poll 0");
Mark Slee256bdc42007-11-27 08:42:19 +0000293 throw TTransportException(TTransportException::UNKNOWN);
Mark Sleea5a783f2007-03-02 19:41:08 +0000294 }
295 }
296
Mark Slee6d56eb92007-07-06 22:28:15 +0000297 struct sockaddr_storage clientAddress;
Mark Sleee8540632006-05-30 09:24:40 +0000298 int size = sizeof(clientAddress);
299 int clientSocket = ::accept(serverSocket_,
300 (struct sockaddr *) &clientAddress,
301 (socklen_t *) &size);
Mark Slee256bdc42007-11-27 08:42:19 +0000302
Martin Kraemeree341cb2007-02-05 21:40:38 +0000303 if (clientSocket < 0) {
David Reissbc3dddb2007-08-22 23:20:24 +0000304 int errno_copy = errno;
David Reiss9b209552008-04-08 06:26:05 +0000305 string errStr = "TServerSocket::acceptImpl() ::accept() " + TOutput::strerror_s(errno_copy);
306 GlobalOutput(errStr.c_str());
David Reissbc3dddb2007-08-22 23:20:24 +0000307 throw TTransportException(TTransportException::UNKNOWN, "accept()", errno_copy);
Mark Sleee8540632006-05-30 09:24:40 +0000308 }
Mark Sleea5a783f2007-03-02 19:41:08 +0000309
310 // Make sure client socket is blocking
311 int flags = fcntl(clientSocket, F_GETFL, 0);
312 if (flags == -1) {
David Reissbc3dddb2007-08-22 23:20:24 +0000313 int errno_copy = errno;
David Reiss9b209552008-04-08 06:26:05 +0000314 string errStr = "TServerSocket::acceptImpl() fcntl() F_GETFL " + TOutput::strerror_s(errno_copy);
315 GlobalOutput(errStr.c_str());
David Reissbc3dddb2007-08-22 23:20:24 +0000316 throw TTransportException(TTransportException::UNKNOWN, "fcntl(F_GETFL)", errno_copy);
Mark Sleea5a783f2007-03-02 19:41:08 +0000317 }
David Reiss9b209552008-04-08 06:26:05 +0000318
Mark Sleea5a783f2007-03-02 19:41:08 +0000319 if (-1 == fcntl(clientSocket, F_SETFL, flags & ~O_NONBLOCK)) {
David Reissbc3dddb2007-08-22 23:20:24 +0000320 int errno_copy = errno;
David Reiss9b209552008-04-08 06:26:05 +0000321 string errStr = "TServerSocket::acceptImpl() fcntl() F_SETFL ~O_NONBLOCK " + TOutput::strerror_s(errno_copy);
322 GlobalOutput(errStr.c_str());
David Reissbc3dddb2007-08-22 23:20:24 +0000323 throw TTransportException(TTransportException::UNKNOWN, "fcntl(F_SETFL)", errno_copy);
Mark Sleea5a783f2007-03-02 19:41:08 +0000324 }
Mark Slee256bdc42007-11-27 08:42:19 +0000325
Mark Slee29050782006-09-29 00:12:30 +0000326 shared_ptr<TSocket> client(new TSocket(clientSocket));
327 if (sendTimeout_ > 0) {
328 client->setSendTimeout(sendTimeout_);
329 }
330 if (recvTimeout_ > 0) {
331 client->setRecvTimeout(recvTimeout_);
Mark Sleea5a783f2007-03-02 19:41:08 +0000332 }
Mark Slee256bdc42007-11-27 08:42:19 +0000333
Mark Slee29050782006-09-29 00:12:30 +0000334 return client;
Mark Sleee8540632006-05-30 09:24:40 +0000335}
336
Mark Slee561b5362007-03-09 19:26:29 +0000337void TServerSocket::interrupt() {
338 if (intSock1_ >= 0) {
339 int8_t byte = 0;
340 if (-1 == send(intSock1_, &byte, sizeof(int8_t), 0)) {
David Reiss9b209552008-04-08 06:26:05 +0000341 int errno_copy = errno;
342 string errStr = "TServerSocket::interrupt() send() " + TOutput::strerror_s(errno_copy);
343 GlobalOutput(errStr.c_str());
Mark Slee561b5362007-03-09 19:26:29 +0000344 }
345 }
346}
347
Mark Sleee8540632006-05-30 09:24:40 +0000348void TServerSocket::close() {
Martin Kraemeree341cb2007-02-05 21:40:38 +0000349 if (serverSocket_ >= 0) {
Mark Sleee8540632006-05-30 09:24:40 +0000350 shutdown(serverSocket_, SHUT_RDWR);
351 ::close(serverSocket_);
352 }
Mark Slee561b5362007-03-09 19:26:29 +0000353 if (intSock1_ >= 0) {
354 ::close(intSock1_);
355 }
356 if (intSock2_ >= 0) {
357 ::close(intSock2_);
358 }
Martin Kraemeree341cb2007-02-05 21:40:38 +0000359 serverSocket_ = -1;
Mark Slee561b5362007-03-09 19:26:29 +0000360 intSock1_ = -1;
361 intSock2_ = -1;
Mark Sleee8540632006-05-30 09:24:40 +0000362}
Marc Slemko6f038a72006-08-03 18:58:09 +0000363
364}}} // facebook::thrift::transport