Coverage Report

Created: 2023-06-07 06:21

/src/h2o/deps/libyrmcds/socket.c
Line
Count
Source (jump to first uncovered line)
1
// (C) 2013 Cybozu et al.
2
3
#include "yrmcds.h"
4
5
#include <sys/socket.h>
6
#include <sys/types.h>
7
#include <sys/time.h>
8
9
0
yrmcds_error yrmcds_shutdown(yrmcds* c) {
10
0
    if( c == NULL )
11
0
        return YRMCDS_BAD_ARGUMENT;
12
0
    if( shutdown(c->sock, SHUT_RD) == -1 ) {
13
0
        return YRMCDS_SYSTEM_ERROR;
14
0
    }
15
0
    return YRMCDS_OK;
16
0
}
17
18
0
int yrmcds_fileno(yrmcds* c) {
19
0
    return c->sock;
20
0
}
21
22
0
yrmcds_error yrmcds_set_timeout(yrmcds* c, int timeout) {
23
0
    if( c == NULL || timeout < 0 )
24
0
        return YRMCDS_BAD_ARGUMENT;
25
26
0
    struct timeval tv;
27
0
    tv.tv_sec = timeout;
28
0
    tv.tv_usec = 0;
29
30
0
    if( setsockopt(c->sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1 )
31
0
        return YRMCDS_SYSTEM_ERROR;
32
0
    if( setsockopt(c->sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1 )
33
0
        return YRMCDS_SYSTEM_ERROR;
34
0
    return YRMCDS_OK;
35
0
}