thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Arroyo (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-4223) Add support to the isServing() method for the C++ library
Date Fri, 09 Jun 2017 16:32:18 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-4223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Erick Arroyo updated THRIFT-4223:
---------------------------------

Hi James,

>From a code review of the preServe() implementation in the Apache Thrift
Library, we found that there might be a possible race condition in this
section of code (TServerFramework.cpp):

void TServerFramework::serve() {

  shared_ptr<TTransport> client;

 shared_ptr<TTransport> inputTransport;

  shared_ptr<TTransport> outputTransport;

  shared_ptr<TProtocol> inputProtocol;

  shared_ptr<TProtocol> outputProtocol;



  // Start the server listening

  serverTransport_->listen();



  // Run the preServe event to indicate server is now listening

  // and that it is safe to connect.

  if (eventHandler_) {

    eventHandler_->preServe();

  }



  // Fetch client from server

  for (;;) {

    try {

      // Dereference any resources from any previous client creation

      // such that a blocking accept does not hold them indefinitely.

      outputProtocol.reset();

      inputProtocol.reset();

      outputTransport.reset();

      inputTransport.reset();

      client.reset();



      // If we have reached the limit on the number of concurrent

      // clients allowed, wait for one or more clients to drain before

      // accepting another.

      {

        Synchronized sync(mon_);

        while (clients_ >= limit_) {

          mon_.wait();

        }

      }



      client = serverTransport_->accept();

Well, the event preServe() is signaled before the infinite for(;;) loop.

Now, we assume that the "accept" call is blocking and waiting for an
incoming connection on the socket. But what about the 6 lines before the
"accept", could there be a race condition there?
Because it’s unclear if these 6 lines of code need to be executed prior to
the first client connecting.

What do you think?

Regards and thanks.

Lic-Ing. Erick Arroyo Blanco
Embedded Software Engineer
RidgeRun Engineering Ltd.www.ridgerun.com
Email: erick.arroyo@ridgerun.com
Mobile: +(506) 86408510
Commercial Center Plaza Magnolia, 3rd floor, East wing. #10-12.
San Juan, La Unión. Cartago. Costa Rica



**************************************************************************************************************************************
Este correo es confidencial y destinado para el uso del individuo a
quien fue dirigido. Si usted no es el usuario destinatario,
tenga presente que usted ha recibido este correo por error y que
cualquier uso, transmision, impresion o copia de este correo esta
estrictamente prohibido. Si usted ha recibido este correo por error,
por favor contacte al emisor.

This email is confidential and intended for the use of the individual
to whom it is addressed. If you are not the intended recipient,
be advised that you have received this email in error and that any
use, dissemination, forwarding, printing, or copying of this email
is strictly prohibited. If you have received this email in error,
please contact the sender.
**************************************************************************************************************************************


On Wed, Jun 7, 2017 at 2:17 PM, Erick Arroyo <erick.arroyo@ridgerun.com>



> Add support to the isServing() method for the C++ library
> ---------------------------------------------------------
>
>                 Key: THRIFT-4223
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4223
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Library
>    Affects Versions: 0.10.0
>         Environment: Linux
>            Reporter: Erick Arroyo
>            Assignee: James E. King, III
>             Fix For: 0.11.0
>
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> It is important to add support to the isServing() method for the C++ library and in the
other supported languages. This method is already exposed on the Java library. 
> This method is very useful to determine when exactly the server is in listening state
and also can be used to fix for example race conditions between the server and the client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message