tomcucinotta / distwalk

Distributed processing emulation tool
GNU General Public License v3.0
1 stars 4 forks source link

Need to use data.u64 in epoll loop #29

Closed tomcucinotta closed 9 months ago

tomcucinotta commented 9 months ago

While dealing with d0e77743, I just noticed that we need to switch to a better use of the data field in epoll event loop(s).

       struct epoll_event {
           uint32_t      events;  /* Epoll events */
           epoll_data_t  data;    /* User data variable */
       };

       union epoll_data {
           void     *ptr;
           int       fd;
           uint32_t  u32;
           uint64_t  u64;
       };

Currently, we use data.fd, that is compared with a few special file descriptors, otherwise we start exec_request() that uses data.u32. Unfortunately, there's quite some likelihood that the 4th, 5th, etc... request would clash with one of the existing file descriptors. So, we need to use the full 64-bits we have there, e.g., by OR-ing one of these

#define DATA_FD (0ul << 32)
#define DATA_CONN_ID (1ul<<32)

like this:

data.u64 = DATA_FD | fd;
data.u64 = DATA_CONN_ID | conn_id;