[Libwebsockets] trouble with external POLL array handling

"Andy Green (林安廸)" andy at warmcat.com
Tue Jan 15 09:25:35 CET 2013


On 15/01/13 16:19, the mail apparently from Edwin van den Oetelaar included:
> Looks alright Andy.
>
> Just in the same line of thought : how about adding an extra break
> from the loop...
> What do you think?
>
>
>      case LWS_CALLBACK_ADD_POLL_FD:
>          pollfds[count_pollfds].fd = (int) (long) user;
>          pollfds[count_pollfds].events = (int) len;
>          pollfds[count_pollfds++].revents = 0;
>          break;
>
>      case LWS_CALLBACK_DEL_POLL_FD:
>          for (n = 0; n < count_pollfds; n++) {
>              if (pollfds[n].fd != (int) (long) user)
>                  continue;
>              /*
>               * swap the end guy into our vacant slot...
>               * works ok if n is the end guy
>               */
>              pollfds[n] = pollfds[count_pollfds - 1];
>              pollfds[count_pollfds - 1].fd = -1;
>              count_pollfds--;
>              break;
>          }
>          break;
>
>      case LWS_CALLBACK_SET_MODE_POLL_FD:
>          for (n = 0; n < count_pollfds; n++)
>              if (pollfds[n].fd == (int) (long) user) {
>                  pollfds[n].events |= (int) (long) len;
>                  break; // HERE
>              }
>          break;
>
>      case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
>          for (n = 0; n < count_pollfds; n++)
>              if (pollfds[n].fd == (int) (long) user) {
>                  pollfds[n].events &= ~(int) (long) len;
>                  break; // HERE
>              }
>          break;

Yes good idea thanks, I added it

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=8db451f3639fc629129bac096a2ed86b0f2c3ff6

-Andy





More information about the Libwebsockets mailing list