Lines Matching defs:ioeh
266 ioevent_t *ioeh;
286 ioeh = &IOE_handles[handle];
288 ioeh->inuse = 1;
290 ioeh->last_index = 0;
291 ioeh->total_free = 0;
292 ioeh->left_events = 0;
293 ioeh->max_index = maximum_fds;
297 ioeh->devpollfd = open("/dev/poll",O_RDWR);
298 DBGMSG(("Opened /dev/poll, set devpollfd = %d\n",ioeh->devpollfd));
299 if (ioeh->devpollfd < 0) {
304 ioeh->pfd = malloc(maximum_fds * sizeof(pollfd_t));
305 if (ioeh->pfd == NULL) {
323 ioevent_t *ioeh;
331 ioeh = &IOE_handles[handle];
332 ioeh->inuse = 0;
334 close(ioeh->devpollfd);
336 free(ioeh->pfd);
340 static void check_handle(ioevent_t *ioeh)
345 for (i = 0; i < ioeh->last_index; i++)
347 if (ioeh->pfd[i].fd == -1)
352 if (unused != ioeh->total_free)
354 unused, ioeh->total_free, used);
372 ioevent_t *ioeh;
377 ioeh = &IOE_handles[handle];
379 CHECK_HANDLE(ioeh);
392 if ((i = write(ioeh->devpollfd, &pollelt, sizeof(pollfd_t))) !=
395 ioeh->devpollfd,i,sizeof(pollfd_t)));
406 retval = addfd(env, ioeh, fd, events);
414 jint addfd(JNIEnv *env, ioevent_t *ioeh, jint fd, jshort events)
418 if (ioeh->total_free)
423 ioeh->total_free--;
424 for (idx = ioeh->last_index - 1; idx >= 0; idx--) {
425 if (ioeh->pfd[idx].fd == -1)
429 else if (ioeh->last_index >= ioeh->max_index)
442 new_total = ioeh->last_index;
444 if (new_total > ioeh->max_index)
445 new_total = ioeh->max_index;
446 for (i = ioeh->last_index; i <= new_total; i++)
448 ioeh->pfd[i].fd = -1;
450 idx = ioeh->last_index;
451 ioeh->total_free = new_total - ioeh->last_index - 1;
453 ioeh->last_index, new_total));
454 ioeh->last_index = new_total;
456 ASSERT((idx >= 0) && (idx <= ioeh->max_index));
457 ASSERT(ioeh->pfd[idx].fd == -1);
458 ioeh->pfd[idx].fd = fd;
459 ioeh->pfd[idx].events = events;
460 ioeh->pfd[idx].revents = 0;
462 CHECK_HANDLE(ioeh);
476 ioevent_t *ioeh;
481 ioeh = &IOE_handles[handle];
493 if (write(ioeh->devpollfd, &pollelt,
502 return removefd(env, ioeh,fd);
508 jint removefd(JNIEnv *env, ioevent_t *ioeh, jint fd)
514 for (i = 0; i < ioeh->last_index; i++)
516 if (ioeh->pfd[i].fd == fd)
518 ioeh->pfd[i].fd = -1;
527 ioeh->left_events = 0; /* Have to go back to the kernel */
528 ioeh->total_free++;
532 if ( (ioeh->last_index > 100) &&
533 (ioeh->total_free > (ioeh->last_index / 3)) )
544 CHECK_HANDLE(ioeh);
545 for (i = ioeh->last_index - 1, j = 0; i > j; i--)
547 if (ioeh->pfd[i].fd != -1)
549 while ( (j < i) && (ioeh->pfd[j].fd != -1) )
551 DBGMSG( ("i=%d,j=%d,ioeh->pfd[j].fd=%d\n",
552 i, j, ioeh->pfd[j].fd) );
555 ASSERT(ioeh->pfd[j].fd == -1);
556 ioeh->pfd[j].fd = ioeh->pfd[i].fd;
557 ioeh->pfd[j].events = ioeh->pfd[i].events;
558 ioeh->pfd[i].fd = -1;
563 ioeh->last_index, j+11));
564 ioeh->last_index = j + 11; /* last_index always 1 greater */
565 ioeh->total_free = 10;
566 CHECK_HANDLE(ioeh);
584 ioevent_t *ioeh;
589 ioeh = &IOE_handles[handle];
601 found = ioctl(ioeh->devpollfd, DP_ISPOLLED, &pfd);
610 for (i = 0; i < ioeh->last_index; i++)
612 if (fd == ioeh->pfd[i].fd)
637 ioevent_t *ioeh;
643 ioeh = &IOE_handles[handle];
660 dopoll.dp_fds=ioeh->pfd;
662 useEvents = ioctl(ioeh->devpollfd, DP_POLL, &dopoll);
664 useEvents = ioctl(ioeh->devpollfd, DP_POLL, &dopoll);
678 if (ioeh->pfd[idx].revents)
680 fdp[count] = ioeh->pfd[idx].fd;
681 reventp[count] = ioeh->pfd[idx].revents;
698 if (ioeh->left_events == 0)
700 useEvents = poll(ioeh->pfd,ioeh->last_index, timeout);
702 useEvents = poll(ioeh->pfd,ioeh->last_index, timeout);
714 ioeh->left_events = useEvents;
719 useEvents = ioeh->left_events;
727 ioeh->left_events -= useEvents; /* left to process */
729 DBGMSG(("waitnative : left %d, use %d, max %d\n",ioeh->left_events,
736 for (idx = 0,count = 0; (idx < ioeh->last_index) &&
739 if (ioeh->pfd[idx].revents)
741 fdp[count] = ioeh->pfd[idx].fd;
742 reventp[count] = ioeh->pfd[idx].revents;
744 ioeh->pfd[idx].revents = 0;
750 ioeh->left_events = 0;