mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-16 15:56:15 -04:00
Fix compile warnings and errors in win32 build.
svn:r575
This commit is contained in:
parent
2e2104f4ce
commit
78d0de30b8
@ -37,6 +37,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
int
|
int
|
||||||
win_read(int fd, void *buf, unsigned int length)
|
win_read(int fd, void *buf, unsigned int length)
|
||||||
{
|
{
|
||||||
@ -65,7 +66,6 @@ win_write(int fd, void *buf, unsigned int length)
|
|||||||
return (dwBytesWritten);
|
return (dwBytesWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
int
|
int
|
||||||
socketpair(int d, int type, int protocol, int *sv)
|
socketpair(int d, int type, int protocol, int *sv)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "tree.h"
|
#define RB_AUGMENT(x) (void)(x)
|
||||||
|
#include "./tree.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "event-internal.h"
|
#include "event-internal.h"
|
||||||
@ -78,8 +79,8 @@ struct event_entry {
|
|||||||
SOCKET sock;
|
SOCKET sock;
|
||||||
int read_pos;
|
int read_pos;
|
||||||
int write_pos;
|
int write_pos;
|
||||||
struct event *ev_read;
|
struct event *read_event;
|
||||||
struct event *ev_write;
|
struct event *write_event;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -93,9 +94,6 @@ compare(struct event_entry *a, struct event_entry *b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_PROTOTYPE(event_map, event_entry, node, compare);
|
|
||||||
RB_GENERATE(event_map, event_entry, node, compare);
|
|
||||||
|
|
||||||
struct win32op {
|
struct win32op {
|
||||||
int fd_setsz;
|
int fd_setsz;
|
||||||
struct win_fd_set *readset_in;
|
struct win_fd_set *readset_in;
|
||||||
@ -103,11 +101,12 @@ struct win32op {
|
|||||||
struct win_fd_set *readset_out;
|
struct win_fd_set *readset_out;
|
||||||
struct win_fd_set *writeset_out;
|
struct win_fd_set *writeset_out;
|
||||||
struct win_fd_set *exset_out;
|
struct win_fd_set *exset_out;
|
||||||
int n_events;
|
|
||||||
int n_events_alloc;
|
|
||||||
RB_HEAD(event_map, event_entry) event_root;
|
RB_HEAD(event_map, event_entry) event_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RB_PROTOTYPE(event_map, event_entry, node, compare);
|
||||||
|
RB_GENERATE(event_map, event_entry, node, compare);
|
||||||
|
|
||||||
void *win32_init (struct event_base *);
|
void *win32_init (struct event_base *);
|
||||||
int win32_insert (void *, struct event *);
|
int win32_insert (void *, struct event *);
|
||||||
int win32_del (void *, struct event *);
|
int win32_del (void *, struct event *);
|
||||||
@ -122,7 +121,8 @@ struct eventop win32ops = {
|
|||||||
win32_del,
|
win32_del,
|
||||||
win32_recalc,
|
win32_recalc,
|
||||||
win32_dispatch,
|
win32_dispatch,
|
||||||
win32_dealloc
|
win32_dealloc,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FD_SET_ALLOC_SIZE(n) ((sizeof(struct win_fd_set) + ((n)-1)*sizeof(SOCKET)))
|
#define FD_SET_ALLOC_SIZE(n) ((sizeof(struct win_fd_set) + ((n)-1)*sizeof(SOCKET)))
|
||||||
@ -161,25 +161,24 @@ static struct event_entry*
|
|||||||
get_event_entry(struct win32op *op, SOCKET s, int create)
|
get_event_entry(struct win32op *op, SOCKET s, int create)
|
||||||
{
|
{
|
||||||
struct event_entry key, *val;
|
struct event_entry key, *val;
|
||||||
key.socket = s;
|
key.sock = s;
|
||||||
val = RB_FIND(&op->event_root, &key);
|
val = RB_FIND(event_map, &op->event_root, &key);
|
||||||
if (val || !create)
|
if (val || !create)
|
||||||
return val;
|
return val;
|
||||||
if (!(val = event_calloc(1, sizeof(struct event_entry)))) {
|
if (!(val = event_calloc(1, sizeof(struct event_entry)))) {
|
||||||
event_warn("%s: calloc", __func__);
|
event_warn("%s: calloc", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
val->socket = s;
|
val->sock = s;
|
||||||
val->read_pos = val->write_pos = -1;
|
val->read_pos = val->write_pos = -1;
|
||||||
RB_INSERT(&op->event_root, val);
|
RB_INSERT(event_map, &op->event_root, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_fd_set(struct win32op *op, struct event_entry *ent, int read)
|
do_fd_set(struct win32op *op, struct event_entry *ent, int read)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
SOCKET s = ent->sock;
|
||||||
SOCKET s = ent->socket;
|
|
||||||
struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
|
struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
|
||||||
if (read) {
|
if (read) {
|
||||||
if (ent->read_pos >= 0)
|
if (ent->read_pos >= 0)
|
||||||
@ -205,8 +204,7 @@ do_fd_set(struct win32op *op, struct event_entry *ent, int read)
|
|||||||
static int
|
static int
|
||||||
do_fd_clear(struct win32op *op, struct event_entry *ent, int read)
|
do_fd_clear(struct win32op *op, struct event_entry *ent, int read)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
int i;
|
||||||
SOCKET s = ent->socket;
|
|
||||||
struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
|
struct win_fd_set *set = read ? op->readset_in : op->writeset_in;
|
||||||
if (read) {
|
if (read) {
|
||||||
i = ent->read_pos;
|
i = ent->read_pos;
|
||||||
@ -252,8 +250,6 @@ win32_init(struct event_base *_base)
|
|||||||
goto err;
|
goto err;
|
||||||
if (!(winop->exset_out = event_malloc(size)))
|
if (!(winop->exset_out = event_malloc(size)))
|
||||||
goto err;
|
goto err;
|
||||||
winop->n_events = 0;
|
|
||||||
winop->n_events_alloc = NEVENT;
|
|
||||||
RB_INIT(&winop->event_root);
|
RB_INIT(&winop->event_root);
|
||||||
winop->readset_in->fd_count = winop->writeset_in->fd_count = 0;
|
winop->readset_in->fd_count = winop->writeset_in->fd_count = 0;
|
||||||
winop->readset_out->fd_count = winop->writeset_out->fd_count
|
winop->readset_out->fd_count = winop->writeset_out->fd_count
|
||||||
@ -268,7 +264,6 @@ win32_init(struct event_base *_base)
|
|||||||
XFREE(winop->readset_out);
|
XFREE(winop->readset_out);
|
||||||
XFREE(winop->writeset_out);
|
XFREE(winop->writeset_out);
|
||||||
XFREE(winop->exset_out);
|
XFREE(winop->exset_out);
|
||||||
XFREE(winop->events);
|
|
||||||
XFREE(winop);
|
XFREE(winop);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -287,7 +282,6 @@ win32_insert(void *op, struct event *ev)
|
|||||||
{
|
{
|
||||||
struct win32op *win32op = op;
|
struct win32op *win32op = op;
|
||||||
struct event_entry *ent;
|
struct event_entry *ent;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ev->ev_events & EV_SIGNAL) {
|
if (ev->ev_events & EV_SIGNAL) {
|
||||||
return (evsignal_add(ev));
|
return (evsignal_add(ev));
|
||||||
@ -299,12 +293,12 @@ win32_insert(void *op, struct event *ev)
|
|||||||
return (-1); /* out of memory */
|
return (-1); /* out of memory */
|
||||||
|
|
||||||
event_debug(("%s: adding event for %d", __func__, (int)ev->ev_fd));
|
event_debug(("%s: adding event for %d", __func__, (int)ev->ev_fd));
|
||||||
if (ev->events & EV_READ) {
|
if (ev->ev_events & EV_READ) {
|
||||||
if (do_fd_set(win32op, ent, 1)<0)
|
if (do_fd_set(win32op, ent, 1)<0)
|
||||||
return (-1);
|
return (-1);
|
||||||
ent->read_event = ev;
|
ent->read_event = ev;
|
||||||
}
|
}
|
||||||
if (ev->events & EV_WRITE) {
|
if (ev->ev_events & EV_WRITE) {
|
||||||
if (do_fd_set(win32op, ent, 1)<0)
|
if (do_fd_set(win32op, ent, 1)<0)
|
||||||
return (-1);
|
return (-1);
|
||||||
ent->write_event = ev;
|
ent->write_event = ev;
|
||||||
@ -317,7 +311,6 @@ win32_del(void *op, struct event *ev)
|
|||||||
{
|
{
|
||||||
struct win32op *win32op = op;
|
struct win32op *win32op = op;
|
||||||
struct event_entry *ent;
|
struct event_entry *ent;
|
||||||
int i, found;
|
|
||||||
|
|
||||||
if (ev->ev_events & EV_SIGNAL)
|
if (ev->ev_events & EV_SIGNAL)
|
||||||
return (evsignal_del(ev));
|
return (evsignal_del(ev));
|
||||||
@ -326,15 +319,15 @@ win32_del(void *op, struct event *ev)
|
|||||||
return (-1);
|
return (-1);
|
||||||
event_debug(("%s: Removing event for %d", __func__, ev->ev_fd));
|
event_debug(("%s: Removing event for %d", __func__, ev->ev_fd));
|
||||||
if (ev == ent->read_event) {
|
if (ev == ent->read_event) {
|
||||||
do_fd_clear(win32op, ev->ev_fd, 1);
|
do_fd_clear(win32op, ent, 1);
|
||||||
ent->read_event = NULL;
|
ent->read_event = NULL;
|
||||||
}
|
}
|
||||||
if (ev == ent->write_event) {
|
if (ev == ent->write_event) {
|
||||||
do_fd_clear(win32op, ev->ev_fd, 0);
|
do_fd_clear(win32op, ent, 0);
|
||||||
ent->write_event = NULL;
|
ent->write_event = NULL;
|
||||||
}
|
}
|
||||||
if (!ent->read_event && !ent->write_event) {
|
if (!ent->read_event && !ent->write_event) {
|
||||||
RB_REMOVE(event_map, ent);
|
RB_REMOVE(event_map, &win32op->event_root, ent);
|
||||||
event_free(ent);
|
event_free(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +354,10 @@
|
|||||||
RelativePath="..\WIN32-Code\misc.h"
|
RelativePath="..\WIN32-Code\misc.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\mm-internal.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\strlcpy-internal.h"
|
RelativePath="..\strlcpy-internal.h"
|
||||||
>
|
>
|
||||||
|
4
evdns.c
4
evdns.c
@ -2956,7 +2956,7 @@ load_nameservers_from_registry(void)
|
|||||||
#undef TRY
|
#undef TRY
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
evdns_config_windows_nameservers(void)
|
evdns_config_windows_nameservers(void)
|
||||||
{
|
{
|
||||||
if (load_nameservers_with_getnetworkparams() == 0)
|
if (load_nameservers_with_getnetworkparams() == 0)
|
||||||
@ -2970,7 +2970,7 @@ evdns_init(void)
|
|||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
evdns_config_windows_nameservers();
|
res = evdns_config_windows_nameservers();
|
||||||
#else
|
#else
|
||||||
res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");
|
res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user