[erlang-questions] how erlang handle multiple processes accepting on a socket?
Benoit Chesneau
bchesneau@REDACTED
Sat Jun 14 21:05:33 CEST 2014
On Sat, Jun 14, 2014 at 1:04 PM, Tony Rogvall <tony@REDACTED> wrote:
> It is one queue per listen socket, using poll/select.
>
> The gen_tcp accept is executed directly in the callers scheduler/thread
> if the socket accept returns ok.
> Otherwise the listen socket is "selected" and an input ready callback will
> run socket accept from a scheduler/thread when the event is triggered.
>
> So the answer is no. The queued accepts are executed as result of
> the (listen) port being scheduled. The listen port actually creates
> new port / socket and pass that to the process that called gen_tcp accept
> in the first place.
>
> While browsing the code, needed to updated myself with the latest
> progress,
> in order to reply to this question, I notice that all accepts are executed
> from the queue regardless how long the queue is. Could this not
> lead to very interesting behavior in extreme cases ?
> (I need to do some fun experiments)
>
> /Tony
>
>
make sens thanks for the answer! Also thanks to Max :)
- benoit
> On 14 jun 2014, at 10:30, Benoit Chesneau <bchesneau@REDACTED> wrote:
>
>
>
>
> On Sat, Jun 14, 2014 at 10:25 AM, Benoit Chesneau <bchesneau@REDACTED>
> wrote:
>
>>
>>
>>
>> On Sat, Jun 14, 2014 at 9:59 AM, Max Lapshin <max.lapshin@REDACTED>
>> wrote:
>>
>>> Driver remembers what processes have asked to notify them about new
>>> connection.
>>>
>>> When new client comes, driver looks for next waiting process, send
>>> message to it and removes his record from list of waiting processes.
>>>
>>> So, nothing magic. Driver is single threaded, but it is scheduled
>>> independently from other processes.
>>>
>>
>> So afaik accepting is only done in one thread right?
>>
>
> hrmm or does it notify them about a read event and let them accept?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> "Installing applications can lead to corruption over time. Applications
> gradually write over each other's libraries, partial upgrades occur, user
> and system errors happen, and minute changes may be unnoticeable and
> difficult to fix"
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140614/efb6c6a2/attachment.htm>
More information about the erlang-questions
mailing list