Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:02:03+00:00 2026-06-15T19:02:03+00:00

Using epoll_wait to manage multiple connections using multiple threads, there is a risk trying

  • 0

Using epoll_wait to manage multiple connections using multiple threads, there is a risk trying to release custom data associated with a closed socket.

Consider the following scenario, where T is the custom data :

  1. Data is received,
  2. Because of 1, thread A deblocks from epoll_wait and processes the event (access T)
  3. At same time, another thread B, wants to close the connection

Thread B can’t assume that T can be safely deleted, eventhough the call to close will immediatly remove the socket from the epoll.

I had the following standard idea :

Maintain a variable within T that gets incremented each time a call to write/read returns EAGAIN, and gets decremented each time the socket is ready.
When close is called, wait for that variable to go down to zero before deleting T.
The issue I experienced is that if close is called, epoll_wait does not return an indication of a cancellation of previous calls to arm the socket.

Anybody had this same problem ? How did you managed to overcome it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:02:05+00:00Added an answer on June 15, 2026 at 7:02 pm

    After many research, I found this recent and remarkable article :
    http://lwn.net/Articles/520012/
    Basically it acknowledge the issue I am describing and speaks about a possible future patch to Linux kernel that allows to extend the epoll API in a way that solves the issue.

    The extension bring a new command called : EPOLL_CTL_DISABLE.
    When it is issued, and by means of return value, the calling thread will know if some other thread has just been deblocked from epoll_wait upon same socket.
    This can help know the safe moment of closure and release of custom data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program using epoll_wait to wait for file descriptors on 64-bit Linux,
I am trying to implement a Comet style (e.g. chat) application using IronPython. While
Using ASP.NET MVC there are situations (such as form submission) that may require a
I am working on a threaded network server using epoll (edge triggered) and threads
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
I'm using epoll_create to wait on a socket. What is the life-cycle of the
I am trying to create a socket server in C for a Collaborative real-time
I'm trying to write a scalable custom web server. Here's what I have so
I'm trying to experiment with using splice ( man 2 splice ) to copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.