diff -ru /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/Makefile wpjabber-1.1.5/wpj_epoll/Makefile --- /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/Makefile Fri Jun 13 13:42:15 2003 +++ wpjabber-1.1.5/wpj_epoll/Makefile Sun Jan 18 19:41:32 2004 @@ -2,7 +2,7 @@ include ../platform-settings CFLAGS=$(COMMON_CFLAGS) -I../jabberd/lib -DHAVE_SSL -LIBS= -lssl -lcrypto +LIBS= -lssl -lcrypto -lepoll JABD=../jabberd jabberd_XODEOBJECTS = \ diff -ru /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/io.c wpjabber-1.1.5/wpj_epoll/io.c --- /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/io.c Tue Jul 1 11:00:17 2003 +++ wpjabber-1.1.5/wpj_epoll/io.c Sun Jan 18 19:37:00 2004 @@ -213,18 +213,18 @@ * dev/epoll set */ int fdop(int fd,int op){ - struct pollfd pfd; - pfd.fd = fd; - pfd.events = op; - pfd.revents = 0; - if (write(io__data->epollfd, &pfd, sizeof(pfd)) != sizeof(pfd)) { + struct epoll_event ev; + ev.events = EPOLLIN | EPOLLOUT | EPOLLERR | EPOLLHUP; + ev.data.u64 = 0; /* really needed? */ + ev.data.fd = fd; + if ((epoll_ctl(io__data->epollfd, op, fd, &ev)) != 0) { log_alert(ZONE,"fdop error"); return -1; } return 0; } -#define ADDFD POLLIN | POLLOUT | POLLERR | POLLHUP -#define REMFD POLLREMOVE +#define ADDFD EPOLL_CTL_ADD +#define REMFD EPOLL_CTL_DEL /* * unlinks a socket from the master list @@ -705,7 +705,7 @@ return new; } -int poll(struct pollfd *ufds, unsigned int nfds, int timeout); +//int poll(struct pollfd *ufds, unsigned int nfds, int timeout); void * _io_connect(void *arg) { @@ -1040,8 +1040,8 @@ int free_size=-1; /* dev/epoll */ - struct pollfd *pfds; - struct evpoll evp; + //struct pollfd *pfds; + struct epoll_event evp[1000]; datatime = iotime = timeGetTimeSec(); /* get sec */ @@ -1399,18 +1399,18 @@ /* ################# ACTIVE READ ######################## */ /* dev/epoll */ - evp.ep_timeout = 0; /* no wait */ - evp.ep_resoff = 0; - nfds = ioctl(io__data->epollfd, EP_POLL, &evp); - pfds = (struct pollfd *) (io__data->epollmap + evp.ep_resoff); + //evp.ep_timeout = 0; /* no wait */ + //evp.ep_resoff = 0; + nfds = epoll_wait(io__data->epollfd, evp, 1000, 0); + //pfds = (struct pollfd *) (io__data->epollmap + evp.ep_resoff); /* check sockets */ server_read_count = 0; /* how often check server for read */ for (i = 0; i < nfds; i++) { /* check if we need to read from server */ - if ((io__data->serverio)&&(pfds[i].fd == io__data->serverio->fd )) { - if (pfds[i].revents & POLLIN) { + if ((io__data->serverio)&&(evp[i].data.fd == io__data->serverio->fd )) { + if (evp[i].events & EPOLLIN) { /* read from server */ server_read_count = 0; @@ -1421,12 +1421,12 @@ } else /* error server */ - if (pfds[i].revents & (POLLHUP|POLLERR)) { + if (evp[i].events & (EPOLLHUP|EPOLLERR)) { io_close(io__data->serverio); }/* error server */ } else - if ((io__data->listenio)&&(pfds[i].fd == io__data->listenio->fd )) { + if ((io__data->listenio)&&(evp[i].data.fd == io__data->listenio->fd )) { /* accept new connection */ cur = NULL; while (cur != ((void *)-1)){ @@ -1481,7 +1481,7 @@ } /* find cur in client hash */ - cur = find_client(pfds[i].fd); + cur = find_client(evp[i].data.fd); if (cur == NULL) continue; /* go */ @@ -1492,8 +1492,8 @@ } /* error */ - if (pfds[i].revents & (POLLHUP|POLLERR)) { - log_alert(ZONE,"socket close - HUB,ERR"); + if (evp[i].events & (EPOLLHUP|EPOLLERR)) { + log_alert(ZONE,"socket close - HUP,ERR"); io_close(cur); temp = cur; close_client(temp); @@ -1501,7 +1501,7 @@ } /* read event */ - if (pfds[i].revents & POLLIN) { + if (evp[i].events & EPOLLIN) { /* can read */ /* update last socket reaction */ cur->last_io = time; @@ -1537,7 +1537,7 @@ }/*read*/ else /* write */ - if (pfds[i].revents & POLLOUT) { + if (evp[i].events & EPOLLOUT) { if (cur->queue != NULL){ /* if something to write */ int ret; @@ -1588,16 +1588,16 @@ /* init /dev/epoll */ - io__data->epollfd = open("/dev/epoll",O_RDWR); + io__data->epollfd = epoll_create(1000); if (io__data->epollfd != -1) { - ioctl(io__data->epollfd, EP_ALLOC,wpj->cfg->max_clients+10); - io__data->epollmap=(char *)mmap(NULL, EP_MAP_SIZE(wpj->cfg->max_clients+10), PROT_READ | PROT_WRITE, MAP_PRIVATE, io__data->epollfd, 0); + //ioctl(io__data->epollfd, EP_ALLOC,wpj->cfg->max_clients+10); + //io__data->epollmap=(char *)mmap(NULL, EP_MAP_SIZE(wpj->cfg->max_clients+10), PROT_READ | PROT_WRITE, MAP_PRIVATE, io__data->epollfd, 0); - log_debug(ZONE,"epoll %d, %p",io__data->epollfd,io__data->epollmap); + //log_debug(ZONE,"epoll %d, %p",io__data->epollfd,io__data->epollmap); } else { - log_alert("epoll error","Can't open /dev/epoll. Read README for more info"); + log_alert("epoll error","Can't epoll_create(). Read README for more info"); } /* init working threads */ @@ -1665,7 +1665,7 @@ RateStop(); /* stop dev/epoll */ - munmap(io__data->epollmap, EP_MAP_SIZE(wpj->cfg->max_clients+10)); + //munmap(io__data->epollmap, EP_MAP_SIZE(wpj->cfg->max_clients+10)); close(io__data->epollfd); log_alert(ZONE,"IO stop end"); diff -ru /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/wpj.h wpjabber-1.1.5/wpj_epoll/wpj.h --- /opt/jabber/devel/wpjabber-1.1.5.orig/wpj_epoll/wpj.h Tue Jun 24 12:28:29 2003 +++ wpjabber-1.1.5/wpj_epoll/wpj.h Sun Jan 18 19:40:37 2004 @@ -31,7 +31,9 @@ #define CLIENT_SOCKET_BUFFER 8192 -#include +//#include +#include +#include #include #include @@ -57,12 +59,12 @@ #include #include -#include +//#include #include #include -#include -#include +//#include +//#include #include #include