Blame
Date:
Mon Jan 11 09:00:47 2021 UTC
Message:
a usleep makes it unnecessary slow, I guess it forces a context switch...
001
2017-10-04
pjp
/* $OpenBSD: imsg.h,v 1.3 2013/12/26 17:32:33 eric Exp $ */
002
2017-10-04
pjp
003
2017-10-04
pjp
/*
004
2017-10-04
pjp
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
005
2017-10-04
pjp
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
006
2017-10-04
pjp
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
007
2017-10-04
pjp
*
008
2017-10-04
pjp
* Permission to use, copy, modify, and distribute this software for any
009
2017-10-04
pjp
* purpose with or without fee is hereby granted, provided that the above
010
2017-10-04
pjp
* copyright notice and this permission notice appear in all copies.
011
2017-10-04
pjp
*
012
2017-10-04
pjp
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
013
2017-10-04
pjp
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
014
2017-10-04
pjp
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
015
2017-10-04
pjp
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
016
2017-10-04
pjp
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
017
2017-10-04
pjp
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
018
2017-10-04
pjp
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
019
2017-10-04
pjp
*/
020
2017-10-04
pjp
021
2017-10-04
pjp
#ifndef _IMSG_H_
022
2017-10-04
pjp
#define _IMSG_H_
023
2017-10-04
pjp
024
2017-10-04
pjp
#ifndef IOV_MAX
025
2017-10-04
pjp
# if defined(_XOPEN_IOV_MAX)
026
2017-10-04
pjp
# define IOV_MAX _XOPEN_IOV_MAX
027
2017-10-04
pjp
# elif defined(DEF_IOV_MAX)
028
2017-10-04
pjp
# define IOV_MAX DEF_IOV_MAX
029
2017-10-04
pjp
# else
030
2017-10-04
pjp
# define IOV_MAX 16
031
2017-10-04
pjp
# endif
032
2017-10-04
pjp
#endif
033
2017-10-04
pjp
034
2017-10-04
pjp
035
2017-10-04
pjp
#define IBUF_READ_SIZE 65535
036
2017-10-04
pjp
#define IMSG_HEADER_SIZE sizeof(struct imsg_hdr)
037
2017-10-04
pjp
#define MAX_IMSGSIZE 16384
038
2017-10-04
pjp
039
2017-10-04
pjp
struct ibuf {
040
2017-10-04
pjp
TAILQ_ENTRY(ibuf) entry;
041
2017-10-04
pjp
u_char *buf;
042
2017-10-04
pjp
size_t size;
043
2017-10-04
pjp
size_t max;
044
2017-10-04
pjp
size_t wpos;
045
2017-10-04
pjp
size_t rpos;
046
2017-10-04
pjp
int fd;
047
2017-10-04
pjp
};
048
2017-10-04
pjp
049
2017-10-04
pjp
struct msgbuf {
050
2017-10-04
pjp
TAILQ_HEAD(, ibuf) bufs;
051
2017-10-04
pjp
u_int32_t queued;
052
2017-10-04
pjp
int fd;
053
2017-10-04
pjp
};
054
2017-10-04
pjp
055
2017-10-04
pjp
struct ibuf_read {
056
2017-10-04
pjp
u_char buf[IBUF_READ_SIZE];
057
2017-10-04
pjp
u_char *rptr;
058
2017-10-04
pjp
size_t wpos;
059
2017-10-04
pjp
};
060
2017-10-04
pjp
061
2017-10-04
pjp
struct imsg_fd {
062
2017-10-04
pjp
TAILQ_ENTRY(imsg_fd) entry;
063
2017-10-04
pjp
int fd;
064
2017-10-04
pjp
};
065
2017-10-04
pjp
066
2017-10-04
pjp
struct imsgbuf {
067
2017-10-04
pjp
TAILQ_HEAD(, imsg_fd) fds;
068
2017-10-04
pjp
struct ibuf_read r;
069
2017-10-04
pjp
struct msgbuf w;
070
2017-10-04
pjp
int fd;
071
2017-10-04
pjp
pid_t pid;
072
2017-10-04
pjp
};
073
2017-10-04
pjp
074
2017-10-04
pjp
#define IMSGF_HASFD 1
075
2017-10-04
pjp
076
2017-10-04
pjp
struct imsg_hdr {
077
2017-10-04
pjp
u_int32_t type;
078
2017-10-04
pjp
u_int16_t len;
079
2017-10-04
pjp
u_int16_t flags;
080
2017-10-04
pjp
u_int32_t peerid;
081
2017-10-04
pjp
u_int32_t pid;
082
2017-10-04
pjp
};
083
2017-10-04
pjp
084
2017-10-04
pjp
struct imsg {
085
2017-10-04
pjp
struct imsg_hdr hdr;
086
2017-10-04
pjp
int fd;
087
2017-10-04
pjp
void *data;
088
2017-10-04
pjp
};
089
2017-10-04
pjp
090
2017-10-04
pjp
091
2017-10-04
pjp
/* buffer.c */
092
2017-10-04
pjp
struct ibuf *ibuf_open(size_t);
093
2017-10-04
pjp
struct ibuf *ibuf_dynamic(size_t, size_t);
094
2017-10-04
pjp
int ibuf_add(struct ibuf *, const void *, size_t);
095
2017-10-04
pjp
void *ibuf_reserve(struct ibuf *, size_t);
096
2017-10-04
pjp
void *ibuf_seek(struct ibuf *, size_t, size_t);
097
2017-10-04
pjp
size_t ibuf_size(struct ibuf *);
098
2017-10-04
pjp
size_t ibuf_left(struct ibuf *);
099
2017-10-04
pjp
void ibuf_close(struct msgbuf *, struct ibuf *);
100
2017-10-04
pjp
int ibuf_write(struct msgbuf *);
101
2017-10-04
pjp
void ibuf_free(struct ibuf *);
102
2017-10-04
pjp
void msgbuf_init(struct msgbuf *);
103
2017-10-04
pjp
void msgbuf_clear(struct msgbuf *);
104
2017-10-04
pjp
int msgbuf_write(struct msgbuf *);
105
2017-10-04
pjp
void msgbuf_drain(struct msgbuf *, size_t);
106
2017-10-04
pjp
107
2017-10-04
pjp
/* imsg.c */
108
2017-10-04
pjp
int available_fds(unsigned int);
109
2017-10-04
pjp
void imsg_init(struct imsgbuf *, int);
110
2017-10-04
pjp
ssize_t imsg_read(struct imsgbuf *);
111
2017-10-04
pjp
ssize_t imsg_get(struct imsgbuf *, struct imsg *);
112
2017-10-04
pjp
int imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
113
2017-10-04
pjp
int, const void *, u_int16_t);
114
2017-10-04
pjp
int imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
115
2017-10-04
pjp
int, const struct iovec *, int);
116
2017-10-04
pjp
struct ibuf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
117
2017-10-04
pjp
u_int16_t);
118
2017-10-04
pjp
int imsg_add(struct ibuf *, const void *, u_int16_t);
119
2017-10-04
pjp
void imsg_close(struct imsgbuf *, struct ibuf *);
120
2017-10-04
pjp
void imsg_free(struct imsg *);
121
2017-10-04
pjp
int imsg_flush(struct imsgbuf *);
122
2017-10-04
pjp
void imsg_clear(struct imsgbuf *);
123
2017-10-04
pjp
124
2017-10-04
pjp
#endif
repomaster@centroid.eu