MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fdset_add

Function fdset_add

dpdk/lib/vhost/fd_man.c:115–140  ·  view source on GitHub ↗

* Register the fd in the fdset with read/write handler and context. */

Source from the content-addressed store, hash-verified

113 * Register the fd in the fdset with read/write handler and context.
114 */
115int
116fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat)
117{
118 int i;
119
120 if (pfdset == NULL || fd == -1)
121 return -1;
122
123 pthread_mutex_lock(&pfdset->fd_mutex);
124 i = pfdset->num < MAX_FDS ? pfdset->num++ : -1;
125 if (i == -1) {
126 pthread_mutex_lock(&pfdset->fd_pooling_mutex);
127 fdset_shrink_nolock(pfdset);
128 pthread_mutex_unlock(&pfdset->fd_pooling_mutex);
129 i = pfdset->num < MAX_FDS ? pfdset->num++ : -1;
130 if (i == -1) {
131 pthread_mutex_unlock(&pfdset->fd_mutex);
132 return -2;
133 }
134 }
135
136 fdset_add_fd(pfdset, i, fd, rcb, wcb, dat);
137 pthread_mutex_unlock(&pfdset->fd_mutex);
138
139 return 0;
140}
141
142/**
143 * Unregister the fd from the fdset.

Callers 5

fdset_pipe_initFunction · 0.85
vhost_user_start_serverFunction · 0.85
vduse_vring_setupFunction · 0.85
vduse_device_createFunction · 0.85

Calls 4

pthread_mutex_lockFunction · 0.85
fdset_shrink_nolockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
fdset_add_fdFunction · 0.85

Tested by

no test coverage detected