MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / tcp_write_on_socket

Function tcp_write_on_socket

net/tcp_common.c:356–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356int tcp_write_on_socket(struct tcp_connection* c, int fd,
357 char *buf, int len, int write_timeout, int async_write_timeout)
358{
359 int n;
360
361 lock_get(&c->write_lock);
362 if (fd < 0) {
363 n = tcp_async_add_chunk(c, buf, len, 0);
364 if (n == 0)
365 n = len;
366 } else if (c->async) {
367 /*
368 * if there is any data pending to write, we have to wait for those chunks
369 * to be sent, otherwise we will completely break the messages' order
370 */
371 if (c->async->pending)
372 n = tcp_async_add_chunk(c, buf, len, 0);
373 else
374 n = tsend_stream_async(c,fd,buf,len, async_write_timeout);
375 } else {
376 n = tsend_stream(fd, buf, len, write_timeout);
377 }
378 lock_release(&c->write_lock);
379 if (fd >= 0 && n > 0)
380 tcp_conn_reset_lifetime(c);
381
382 return n;
383}
384
385/* returns :
386 * 0 - in case of success

Callers 6

smpp_send_bufFunction · 0.85
proto_bin_sendFunction · 0.85
hep_tcp_or_tls_sendFunction · 0.85
proto_msrp_sendFunction · 0.85
_tcp_write_on_socketFunction · 0.85
proto_tcp_sendFunction · 0.85

Calls 5

lock_getFunction · 0.85
tcp_async_add_chunkFunction · 0.85
tsend_stream_asyncFunction · 0.85
tsend_streamFunction · 0.85
lock_releaseFunction · 0.85

Tested by

no test coverage detected