+inline fde_t *
+comm_locate_fd(int fd)
+{
+ int bucket = fd % FD_HASH_SIZE;
+ dlink_list *list = &fd_table[bucket];
+ dlink_node *n;
+
+ DLINK_FOREACH(n, list->head)
+ {
+ fde_t *F = (fde_t *) n->data;
+
+ if (F->fd == fd)
+ return F;
+ }
+
+ return NULL;
+}
+
+inline fde_t *
+comm_add_fd(int fd)
+{
+ fde_t *F = comm_locate_fd(fd);
+ dlink_list *list;
+
+ if (F != NULL)
+ return F;
+
+ F = calloc(sizeof(fde_t), 1);
+ F->fd = fd;
+ list = &fd_table[fd % FD_HASH_SIZE];
+ dlinkAdd(F, &F->node, list);
+
+ return F;
+}
+
+inline void
+comm_remove_fd(int fd)
+{
+ int bucket = fd % FD_HASH_SIZE;
+ fde_t *F;
+ dlink_list *list = &fd_table[bucket];
+
+ F = comm_locate_fd(fd);
+ if (F == NULL)
+ return;
+
+ dlinkDelete(&F->node, list);
+ MyFree(F);
+}
+