summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/deps/libyrmcds/close.c
blob: d19ae7659be4eb4d3451e7d591abdfcc1bfd12eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// (C) 2013 Cybozu.

#include "yrmcds.h"

#include <stdlib.h>
#include <unistd.h>

yrmcds_error yrmcds_close(yrmcds* c) {
    if( c == NULL )
        return YRMCDS_BAD_ARGUMENT;
    if( c->sock == -1 )
        return YRMCDS_OK;

    close(c->sock);
    c->sock = -1;
#ifndef LIBYRMCDS_NO_INTERNAL_LOCK
    pthread_mutex_destroy(&(c->lock));
#endif
    free(c->recvbuf);
    c->recvbuf = NULL;
    free(c->decompressed);
    c->decompressed = NULL;
    return YRMCDS_OK;
}