src/lib/fifo.c
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 176 src/fifo.c@6750d50ee8cd
permissions -rw-r--r--
some of the lib/transport stuff compiles
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
     1
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
     2
#include "fifo.h"
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
     3
#include "transport_fd.h"
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
#include <stdlib.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
#include <sys/types.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
#include <sys/stat.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
#include <fcntl.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
#include <string.h>
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    11
/**
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    12
 * Our transport_type
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    13
 */
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    14
extern const struct transport_type fifo_type;
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    15
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    16
/**
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    17
 * The fifo state
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    18
 */
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
struct fifo {
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    20
    /** The FD-based state */
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    21
    struct transport_fd base_fd;
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
    
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    23
    /** Path to the fifo */
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
    char *path;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
};
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
 * (re)open the fifo, closing it if already open, and keeping any event callbacks registered.
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
 */
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    30
static err_t fifo_open (struct fifo *fifo, error_t *err)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
{
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    32
    int _fd;
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    34
    // open(2) the path in non-blocking read-only mode
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    35
    if ((_fd = open(fifo->path, O_RDONLY | O_NONBLOCK)) < 0)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
        RETURN_SET_ERROR_ERRNO(err, ERR_OPEN);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
    // set the new fd
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    39
    if ((ERROR_CODE(err) = transport_fd_set(&fifo->base_fd, _fd)))
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
        return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
    
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    42
    // use default transport event-based behaviour
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    43
    if ((ERROR_CODE(err) = transport_fd_defaults(&fifo->base_fd)))
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    44
        return ERROR_CODE(err);
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    45
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
    // ok
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
/**
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    51
 * Deinit the fifo, releasing all resources
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
 */
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    53
static void fifo_deinit (struct fifo *fifo)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
{
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    55
    // deinit base
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    56
    transport_fd_deinit(&fifo->base_fd);
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
    // release the path
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
    free(fifo->path);
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    60
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    61
    fifo->path = NULL;
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    62
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
 * sock_stream_methods::read implementation.
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
 *
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
 * Try and do a normal sock_fd_read call, but re-open with EAGAIN on EOF
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
 */
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    69
err_t fifo_read (transport_t *transport, void *buf, size_t *len, struct error_info *err)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
{
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    71
    struct fifo *fifo = transport_check(transport, &fifo_type);
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    73
    // trap READ_EOF
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    74
    if (transport_fd__read(transport, buf, len, err) != ERR_EOF)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
        return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
    
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    77
    // re-open it
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    78
    // XXX: re-add events?
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
    if (fifo_open(fifo, err))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
        goto error;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
    // ok, act as if it was EAGAIN
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
    *len = 0;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
error:
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
    return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
/**
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
 * sock_stream_methods::release implementation
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
 */
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    94
static void fifo__deinit (transport_t *transport)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
{
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
    96
    struct fifo *fifo = transport_check(transport, &fifo_type);
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
    
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
    98
    fifo_deinit(fifo);
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
}
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
/*
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
 * Our sock_stream_type
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
 */
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
   104
const struct transport_type fifo_type = {
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   105
    .base_type = {
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   106
        .parent     = &transport_fd_type.base_type,
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   107
    },
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   108
    .methods = {
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   109
        .read       = fifo_read,
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   110
        .write      = NULL,
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   111
        .events     = transport_fd__events,
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   112
        .deinit     = fifo__deinit,
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
    },
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
};
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   116
/**
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   117
 * Deinit and free
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   118
 */
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   119
static void fifo_destroy (struct fifo *fifo)
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   120
{
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   121
    fifo_deinit(fifo);
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   122
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   123
    free(fifo);
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   124
}
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   125
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
   126
err_t fifo_open_read (struct transport_info *transport_info, transport_t **transport_ptr, struct event_base *ev_base,
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
   127
        const char *path, error_t *err)
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
{
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
    struct fifo *fifo;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
    // alloc
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
    if ((fifo = calloc(1, sizeof(*fifo))) == NULL)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
        return SET_ERROR(err, ERR_CALLOC);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
    // copy the path
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   136
    if ((fifo->path = strdup(path)) == NULL)
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
        return SET_ERROR(err, ERR_STRDUP);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   139
    // init
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   140
    transport_init(&fifo->base_fd.base, &fifo_type, transport_info);
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   141
    transport_fd_init(&fifo->base_fd, ev_base, TRANSPORT_FD_INVALID);
157
1e5674d0eec4 fixed fifo
Tero Marttila <terom@fixme.fi>
parents: 139
diff changeset
   142
    
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
    // open the fifo
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
    if (fifo_open(fifo, err))
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
        goto error;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
    // ok
176
6750d50ee8cd modify transport to use the new object_* stuff, along with transport_fd and fifo
Tero Marttila <terom@fixme.fi>
parents: 161
diff changeset
   148
    *transport_ptr = &fifo->base_fd.base;
118
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
    return SUCCESS;
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
error:
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
    // cleanup
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
    fifo_destroy(fifo);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
    return ERROR_CODE(err);
05b8d5150313 implement fifo (sock_fifo.c) and test_fifo
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
}