Lines Matching refs:sockets
42 curl_socket_t *sockets; member
54 static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention) in removeFd() argument
61 for(i = 0; i < sockets->count; ++i) { in removeFd()
62 if(sockets->sockets[i] == fd) { in removeFd()
63 if(i < sockets->count - 1) in removeFd()
64 memmove(&sockets->sockets[i], &sockets->sockets[i + 1], in removeFd()
65 sizeof(curl_socket_t) * (sockets->count - (i + 1))); in removeFd()
66 --sockets->count; in removeFd()
75 static int addFd(struct Sockets *sockets, curl_socket_t fd, const char *what) in addFd() argument
82 removeFd(sockets, fd, 0); in addFd()
86 if(!sockets->sockets) { in addFd()
87 sockets->sockets = malloc(sizeof(curl_socket_t) * 20U); in addFd()
88 if(!sockets->sockets) in addFd()
90 sockets->max_count = 20; in addFd()
92 else if(sockets->count + 1 > sockets->max_count) { in addFd()
93 curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) * in addFd()
94 (sockets->max_count + 20)); in addFd()
98 sockets->sockets = ptr; in addFd()
99 sockets->max_count += 20; in addFd()
104 sockets->sockets[sockets->count] = fd; in addFd()
105 ++sockets->count; in addFd()
118 struct ReadWriteSockets *sockets = userp; in curlSocketCallback() local
130 if(addFd(&sockets->read, s, "read")) in curlSocketCallback()
134 if(addFd(&sockets->write, s, "write")) in curlSocketCallback()
138 removeFd(&sockets->read, s, 1); in curlSocketCallback()
139 removeFd(&sockets->write, s, 0); in curlSocketCallback()
216 static void updateFdSet(struct Sockets *sockets, fd_set* fdset, in updateFdSet() argument
220 for(i = 0; i < sockets->count; ++i) { in updateFdSet()
221 FD_SET(sockets->sockets[i], fdset); in updateFdSet()
222 if(*maxFd < sockets->sockets[i] + 1) { in updateFdSet()
223 *maxFd = sockets->sockets[i] + 1; in updateFdSet()
244 struct Sockets *sockets, fd_set *fdset, in checkFdSet() argument
249 for(i = 0; i < sockets->count; ++i) { in checkFdSet()
250 if(FD_ISSET(sockets->sockets[i], fdset)) { in checkFdSet()
251 result = socket_action(curl, sockets->sockets[i], evBitmask, name); in checkFdSet()
263 struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; in testone() local
291 multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets); in testone()
310 updateFdSet(&sockets.read, &readSet, &maxFd); in testone()
311 updateFdSet(&sockets.write, &writeSet, &maxFd); in testone()
327 if(checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read")) { in testone()
331 if(checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write")) { in testone()
362 free(sockets.read.sockets); in testone()
363 free(sockets.write.sockets); in testone()