lib update
This commit is contained in:
parent
0b68a8b0f9
commit
cfb173889b
26
event.c
26
event.c
@ -87,12 +87,12 @@ struct event_fd * event_add_fd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type & FD_READ) {
|
if (type & FD_READ) {
|
||||||
entry->flags = (callback != NULL) ? (entry->flags | FD_READ) : (entry->flags & ~FD_READ);
|
entry->flags = (callback != NULL) ? (entry->flags | FD_READ | EVENT_NEW) : (entry->flags & ~FD_READ);
|
||||||
entry->read_cb = callback;
|
entry->read_cb = callback;
|
||||||
entry->read_priv = privdata;
|
entry->read_priv = privdata;
|
||||||
|
|
||||||
} else if (type & FD_WRITE) {
|
} else if (type & FD_WRITE) {
|
||||||
entry->flags = (callback != NULL) ? (entry->flags | FD_WRITE) : (entry->flags & ~FD_WRITE);
|
entry->flags = (callback != NULL) ? (entry->flags | FD_WRITE | EVENT_NEW) : (entry->flags & ~FD_WRITE);
|
||||||
entry->write_cb = callback;
|
entry->write_cb = callback;
|
||||||
entry->write_priv = privdata;
|
entry->write_priv = privdata;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ int event_loop(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* timeout not elapsed, exit search (since list is sorted) */
|
/* first timeout not elapsed, exit search (since list is sorted) */
|
||||||
if (cmp_timeval(&entry->nextrun, &now) == -1)
|
if (cmp_timeval(&entry->nextrun, &now) == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -255,15 +255,19 @@ int event_loop(void)
|
|||||||
if (entry->flags & EVENT_DELETE) {
|
if (entry->flags & EVENT_DELETE) {
|
||||||
list_del(&entry->list);
|
list_del(&entry->list);
|
||||||
free(entry);
|
free(entry);
|
||||||
|
continue;
|
||||||
|
|
||||||
} else if (entry->flags & FD_READ) {
|
}
|
||||||
|
|
||||||
|
if (entry->flags & FD_READ) {
|
||||||
if (readfds == NULL) {
|
if (readfds == NULL) {
|
||||||
readfds = &fdsets[0];
|
readfds = &fdsets[0];
|
||||||
FD_ZERO(readfds);
|
FD_ZERO(readfds);
|
||||||
}
|
}
|
||||||
FD_SET(entry->fd, readfds);
|
FD_SET(entry->fd, readfds);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (entry->flags & FD_WRITE) {
|
if (entry->flags & FD_WRITE) {
|
||||||
if (writefds == NULL) {
|
if (writefds == NULL) {
|
||||||
writefds = &fdsets[1];
|
writefds = &fdsets[1];
|
||||||
FD_ZERO(writefds);
|
FD_ZERO(writefds);
|
||||||
@ -280,23 +284,17 @@ int event_loop(void)
|
|||||||
* after an error.
|
* after an error.
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
} else {
|
|
||||||
list_for_each_entry(entry, &event_fd_list, list) {
|
|
||||||
if ((entry->flags & EVENT_NEW) != 0) {
|
|
||||||
/* entry has just been added, execute it next round */
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entry->flags & FD_READ) && FD_ISSET(entry->fd, readfds))
|
list_for_each_entry(entry, &event_fd_list, list) {
|
||||||
|
if (((entry->flags & (FD_READ | EVENT_NEW)) == FD_READ) && FD_ISSET(entry->fd, readfds))
|
||||||
if (entry->read_cb(entry->fd, entry->read_priv) != 0)
|
if (entry->read_cb(entry->fd, entry->read_priv) != 0)
|
||||||
entry->flags |= EVENT_DELETE;
|
entry->flags |= EVENT_DELETE;
|
||||||
|
|
||||||
if ((entry->flags & FD_WRITE) && FD_ISSET(entry->fd, writefds))
|
if (((entry->flags & (FD_WRITE | EVENT_NEW)) == FD_WRITE) && FD_ISSET(entry->fd, writefds))
|
||||||
if (entry->write_cb(entry->fd, entry->write_priv) != 0)
|
if (entry->write_cb(entry->fd, entry->write_priv) != 0)
|
||||||
entry->flags |= EVENT_DELETE;
|
entry->flags |= EVENT_DELETE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
free(fdsets);
|
free(fdsets);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,6 @@ int tcp_connect_error(int fd)
|
|||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
errno = err;
|
errno = err;
|
||||||
log_print(LOG_ERROR, "tcp_connect_error()");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user