You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Casagrande, Norman" <no...@last.fm> on 2009/07/10 12:51:28 UTC
Stopping persistent connections on TThreadedServer (C++ only?)
Hi,
Apparently TThreadedServer (and TThreadPoolServer) does not stop the
tasks that are waiting on a persistent connection even if the server is
halted with stop() or its transport is closed.
Looking at the code (ThreadedServer.cpp) it seems TThreadedServer is
waiting here:
230 Synchronized s(tasksMonitor_);
231 while (!tasks_.empty()) {
232 tasksMonitor_.wait();
233 }
The task is stuck here:
61 while (processor_->process(input_, output_)) {
62 if (!input_->getTransport()->peek()) {
63 break;
64 }
65 }
Which means that in the TSocket.cpp code the task is waiting here:
108 int r = recv(socket_, &buf, 1, MSG_PEEK);
The socket is local, so it never gets invalidated thus waiting forever.
Any suggestion?
--
Norman
RE: Stopping persistent connections on TThreadedServer (C++ only?)
Posted by "Casagrande, Norman" <no...@last.fm>.
It does not like .patch, sorry about that.
--
Norman
> -----Original Message-----
> From: Casagrande, Norman
> Sent: 10 July 2009 12:22
> To: thrift-dev@incubator.apache.org
> Subject: RE: Stopping persistent connections on TThreadedServer (C++
only?)
>
> Here's a simple patch to address the issue. Note that TSocket should
> also be changed if you want to avoid the TTransportException exception
> being thrown.
>
> --
> Norman Casagrande
> Head of Music Research
> last.fm
>
>
> > -----Original Message-----
> > From: Casagrande, Norman
> > Sent: 10 July 2009 11:51
> > To: thrift-dev@incubator.apache.org
> > Subject: Stopping persistent connections on TThreadedServer (C++
> only?)
> >
> > Hi,
> >
> > Apparently TThreadedServer (and TThreadPoolServer) does not stop the
> > tasks that are waiting on a persistent connection even if the server
> is
> > halted with stop() or its transport is closed.
> >
> > Looking at the code (ThreadedServer.cpp) it seems TThreadedServer is
> > waiting here:
> >
> > 230 Synchronized s(tasksMonitor_);
> > 231 while (!tasks_.empty()) {
> > 232 tasksMonitor_.wait();
> > 233 }
> >
> > The task is stuck here:
> >
> > 61 while (processor_->process(input_, output_)) {
> > 62 if (!input_->getTransport()->peek()) {
> > 63 break;
> > 64 }
> > 65 }
> >
> > Which means that in the TSocket.cpp code the task is waiting here:
> >
> > 108 int r = recv(socket_, &buf, 1, MSG_PEEK);
> >
> > The socket is local, so it never gets invalidated thus waiting
> forever.
> >
> > Any suggestion?
> >
> > --
> > Norman
RE: Stopping persistent connections on TThreadedServer (C++ only?)
Posted by "Casagrande, Norman" <no...@last.fm>.
Here's a simple patch to address the issue. Note that TSocket should
also be changed if you want to avoid the TTransportException exception
being thrown.
--
Norman Casagrande
Head of Music Research
last.fm
> -----Original Message-----
> From: Casagrande, Norman
> Sent: 10 July 2009 11:51
> To: thrift-dev@incubator.apache.org
> Subject: Stopping persistent connections on TThreadedServer (C++
only?)
>
> Hi,
>
> Apparently TThreadedServer (and TThreadPoolServer) does not stop the
> tasks that are waiting on a persistent connection even if the server
is
> halted with stop() or its transport is closed.
>
> Looking at the code (ThreadedServer.cpp) it seems TThreadedServer is
> waiting here:
>
> 230 Synchronized s(tasksMonitor_);
> 231 while (!tasks_.empty()) {
> 232 tasksMonitor_.wait();
> 233 }
>
> The task is stuck here:
>
> 61 while (processor_->process(input_, output_)) {
> 62 if (!input_->getTransport()->peek()) {
> 63 break;
> 64 }
> 65 }
>
> Which means that in the TSocket.cpp code the task is waiting here:
>
> 108 int r = recv(socket_, &buf, 1, MSG_PEEK);
>
> The socket is local, so it never gets invalidated thus waiting
forever.
>
> Any suggestion?
>
> --
> Norman