view src/lib/iobuffer-internal.h @ 532:3b53dd1280c6 HEAD

I/O buffers now use real blocking instead of setting up a sub-ioloop to poll(). alarm() is called every 30 secs to send SIGHUP and break out of the read/write calls, so the given timeout values aren't exact. Also some other cleanups, like not including ioloop.h in [io]buffer.h which broke several other files which hadn't included it itself..
author Timo Sirainen <tss@iki.fi>
date Mon, 28 Oct 2002 06:18:26 +0200
parents 1f0e7229ee58
children 1f1ff728ff65
line wrap: on
line source

#ifndef __IOBUFFER_INTERNAL_H
#define __IOBUFFER_INTERNAL_H

#include "ioloop.h" /* TimeoutFunc */

/* This file is private to IBuffer and OBuffer implementation */

typedef struct _IOBuffer _IOBuffer;

struct _IOBuffer {
	Pool pool;
	int refcount;

	void (*close)(_IOBuffer *buf);
	void (*destroy)(_IOBuffer *buf);
	void (*set_max_size)(_IOBuffer *buf, size_t max_size);
	void (*set_blocking)(_IOBuffer *buf, int timeout_msecs,
			     void (*timeout_func)(void *), void *context);
};

void _io_buffer_init(Pool pool, _IOBuffer *buf);
void _io_buffer_ref(_IOBuffer *buf);
void _io_buffer_unref(_IOBuffer *buf);
void _io_buffer_close(_IOBuffer *buf);
void _io_buffer_set_max_size(_IOBuffer *buf, size_t max_size);
void _io_buffer_set_blocking(_IOBuffer *buf, int timeout_msecs,
			     void (*timeout_func)(void *), void *context);

#define GET_TIMEOUT_TIME(fbuf) \
        ((fbuf)->timeout_msecs == 0 ? 0 : \
	 time(NULL) + ((fbuf)->timeout_msecs / 1000))
#define BUFFER_IS_BLOCKING(fbuf) \
	((fbuf)->timeout_msecs != 0)

#endif