Changeset f36cd97 for select.c


Ignore:
Timestamp:
Dec 17, 2008, 5:12:37 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
1895c29
Parents:
1631825
git-author:
Nelson Elhage <nelhage@mit.edu> (12/17/08 15:44:15)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/17/08 17:12:37)
Message:
Add a void* data to owl_dispatch and pass it around.

Add a void* data field for the use of dispatches, and pass around the
owl_dispatch. This allows one dispatch function to be used for
multiple fd's, and lets us eliminate perl-specific code from the
dispatch loop. In addition, we need to add a destructor to
owl_dispatch so that perl dispatches can have their SV* decref'd on
destroy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • select.c

    rc675b39 rf36cd97  
    133133    d = (owl_dispatch*)owl_list_get_element(dl, elt);
    134134    owl_list_remove_element(dl, elt);
    135     if (d->pfunc) {
    136       owl_perlconfig_dispatch_free(d);
     135    if (d->destroy) {
     136      d->destroy(d);
    137137    }
    138138    owl_free(d);
     
    152152  if (elt != -1) {
    153153    d = (owl_dispatch*)owl_list_get_element(owl_global_get_dispatchlist(&g), elt);
    154     if (d->pfunc == NULL) {
     154    if (d->cfunc != owl_perlconfig_dispatch) {
    155155      /* don't mess with non-perl dispatch functions from here. */
    156156      return 1;
     
    160160  d = malloc(sizeof(owl_dispatch));
    161161  d->fd = fd;
    162   d->cfunc = NULL;
    163   d->pfunc = cb;
     162  d->cfunc = owl_perlconfig_dispatch;
     163  d->destroy = owl_perlconfig_dispatch_free;
     164  d->data = cb;
    164165  owl_select_add_dispatch(d);
    165166  return 0;
     
    174175  if (elt != -1) {
    175176    d = (owl_dispatch*)owl_list_get_element(owl_global_get_dispatchlist(&g), elt);
    176     if (d->pfunc != NULL) {
     177    if (d->cfunc == owl_perlconfig_dispatch) {
    177178      owl_select_remove_dispatch(fd);
    178179      return 0;
     
    216217    if (d != NULL && FD_ISSET(d->fd, fds)) {
    217218      if (d->cfunc != NULL) {
    218         (d->cfunc)();
    219       }
    220       else if (d->pfunc != NULL) {
    221         owl_perlconfig_do_dispatch(d);
     219        d->cfunc(d);
    222220      }
    223221    }
Note: See TracChangeset for help on using the changeset viewer.