MCPcopy Create free account
hub / github.com/corosync/corosync / sam_safe_write

Function sam_safe_write

lib/sam.c:352–375  ·  view source on GitHub ↗

* Wrapper on top of write(2) function. It handles EAGAIN and EINTR states and sends whole buffer if possible. */

Source from the content-addressed store, hash-verified

350 * Wrapper on top of write(2) function. It handles EAGAIN and EINTR states and sends whole buffer if possible.
351 */
352static size_t sam_safe_write (
353 int d,
354 const void *buf,
355 size_t nbyte)
356{
357 ssize_t bytes_write;
358 ssize_t tmp_bytes_write;
359
360 bytes_write = 0;
361
362 do {
363 tmp_bytes_write = write (d, (const char *)buf + bytes_write,
364 (nbyte - bytes_write > SSIZE_MAX) ? SSIZE_MAX : nbyte - bytes_write);
365
366 if (tmp_bytes_write == -1) {
367 if (!(errno == EAGAIN || errno == EINTR))
368 return -1;
369 } else {
370 bytes_write += tmp_bytes_write;
371 }
372 } while (bytes_write != nbyte);
373
374 return (bytes_write);
375}
376
377/*
378 * Wrapper on top of read(2) function. It handles EAGAIN and EINTR states and reads whole buffer if possible.

Callers 7

sam_data_store_nolockFunction · 0.85
sam_startFunction · 0.85
sam_stop_nolockFunction · 0.85
sam_hc_sendFunction · 0.85
sam_mark_failedFunction · 0.85
sam_parent_reply_sendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected