Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/ypldap/yp.c
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | while ((ye = TAILQ_FIRST(&env->sc_yp->yd_events)) != NULL) { | ||||
free(ye); | free(ye); | ||||
} | } | ||||
} | } | ||||
void | void | ||||
yp_enable_events(void) | yp_enable_events(void) | ||||
{ | { | ||||
int i; | int i; | ||||
extern fd_set svc_fdset; | extern fd_set svc_fdset; | ||||
struct yp_event *ye; | struct yp_event *ye; | ||||
for (i = 0; i < getdtablesize(); i++) { | for (i = 0; i < FD_SETSIZE; i++) { | ||||
bapt: Why? | |||||
araujoAuthorUnsubmitted Not Done Inline ActionsThere are two ways to do it:
So, for safety and as it works properly, I choose to use FD_ISSET that has a size of 1024 for the FD. Instead of to choose getdtablesize(), although getdtablesize() for me will be better than FD_ISSET, as getdtablesize() can be tuned. But, needs to remove FD_ISSET. Both ways I'm ok with it. If you think the tuned one is prefered, I can change the code to use getdtablesize() without any problem, as it works too. However, getdtablesize() will be slower than FD_SETSIZE and we might don't need calloc so much. araujo: There are two ways to do it:
1) if use select(2) where we use FD_ISSET we can't calloc all the… | |||||
if (FD_ISSET(i, &svc_fdset)) { | if (FD_ISSET(i, &svc_fdset)) { | ||||
if ((ye = calloc(1, sizeof(*ye))) == NULL) | if ((ye = calloc(1, sizeof(*ye))) == NULL) | ||||
fatal(NULL); | fatal(NULL); | ||||
event_set(&ye->ye_event, i, EV_READ, yp_fd_event, NULL); | event_set(&ye->ye_event, i, EV_READ, yp_fd_event, NULL); | ||||
event_add(&ye->ye_event, NULL); | event_add(&ye->ye_event, NULL); | ||||
TAILQ_INSERT_TAIL(&env->sc_yp->yd_events, ye, ye_entry); | TAILQ_INSERT_TAIL(&env->sc_yp->yd_events, ye, ye_entry); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 555 Lines • Show Last 20 Lines |
Why?