Lines Matching refs:connection

52  * safe_write writes data to the specified connection and tries to do it in
58 safe_write(struct cached_connection_ *connection, const void *data,
74 nevents = _kevent(connection->write_queue, NULL, 0, &eventlist,
77 s_result = _sendto(connection->sockfd, data + result,
96 * safe_read reads data from connection and tries to do it in the very safe
102 safe_read(struct cached_connection_ *connection, void *data, size_t data_size)
117 nevents = _kevent(connection->read_queue, NULL, 0, &eventlist,
120 s_result = _read(connection->sockfd, data + result,
138 * Sends the credentials information to the connection along with the
142 send_credentials(struct cached_connection_ *connection, int type)
168 EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
170 (void)_kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
172 nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1,
175 result = _sendmsg(connection->sockfd, &mhdr,
177 EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD,
179 _kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL);
186 * Opens the connection with the specified params. Initializes all kqueues.
236 __close_cached_connection(struct cached_connection_ *connection)
238 assert(connection != NULL);
240 _close(connection->sockfd);
241 _close(connection->read_queue);
242 _close(connection->write_queue);
243 free(connection);
252 __cached_write(struct cached_connection_ *connection, const char *entry_name,
261 result = send_credentials(connection, CET_WRITE_REQUEST);
266 result = safe_write(connection, &name_size, sizeof(size_t));
270 result = safe_write(connection, &key_size, sizeof(size_t));
274 result = safe_write(connection, &data_size, sizeof(size_t));
278 result = safe_write(connection, entry_name, name_size);
282 result = safe_write(connection, key, key_size);
286 result = safe_write(connection, data, data_size);
290 result = safe_read(connection, &error_code, sizeof(int));
304 __cached_read(struct cached_connection_ *connection, const char *entry_name,
311 assert(connection != NULL);
315 result = send_credentials(connection, CET_READ_REQUEST);
320 result = safe_write(connection, &name_size, sizeof(size_t));
324 result = safe_write(connection, &key_size, sizeof(size_t));
328 result = safe_write(connection, entry_name, name_size);
332 result = safe_write(connection, key, key_size);
336 result = safe_read(connection, &rec_error_code, sizeof(int));
345 result = safe_read(connection, &result_size, sizeof(size_t));
355 result = safe_read(connection, data, result_size);
367 * Initializes the mp_write_session. For such a session the new connection
377 struct cached_connection_ *connection, *retval;
383 connection = __open_cached_connection(params);
384 if (connection == NULL)
386 connection->mp_flag = 1;
388 result = send_credentials(connection, CET_MP_WRITE_SESSION_REQUEST);
393 result = safe_write(connection, &name_size, sizeof(size_t));
397 result = safe_write(connection, entry_name, name_size);
401 result = safe_read(connection, &error_code, sizeof(int));
410 __close_cached_connection(connection);
412 retval = connection;
484 struct cached_connection_ *connection, *retval;
490 connection = __open_cached_connection(params);
491 if (connection == NULL)
493 connection->mp_flag = 1;
495 result = send_credentials(connection, CET_MP_READ_SESSION_REQUEST);
500 result = safe_write(connection, &name_size, sizeof(size_t));
504 result = safe_write(connection, entry_name, name_size);
508 result = safe_read(connection, &error_code, sizeof(int));
517 __close_cached_connection(connection);
519 retval = connection;