Revision 13661089 qemu-char.c
b/qemu-char.c | ||
---|---|---|
168 | 168 |
return s->get_msgfd ? s->get_msgfd(s) : -1; |
169 | 169 |
} |
170 | 170 |
|
171 |
int qemu_chr_add_client(CharDriverState *s, int fd) |
|
172 |
{ |
|
173 |
return s->chr_add_client ? s->chr_add_client(s, fd) : -1; |
|
174 |
} |
|
175 |
|
|
171 | 176 |
void qemu_chr_accept_input(CharDriverState *s) |
172 | 177 |
{ |
173 | 178 |
if (s->chr_accept_input) |
... | ... | |
2146 | 2151 |
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); |
2147 | 2152 |
} |
2148 | 2153 |
|
2154 |
static int tcp_chr_add_client(CharDriverState *chr, int fd) |
|
2155 |
{ |
|
2156 |
TCPCharDriver *s = chr->opaque; |
|
2157 |
if (s->fd != -1) |
|
2158 |
return -1; |
|
2159 |
|
|
2160 |
socket_set_nonblock(fd); |
|
2161 |
if (s->do_nodelay) |
|
2162 |
socket_set_nodelay(fd); |
|
2163 |
s->fd = fd; |
|
2164 |
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL); |
|
2165 |
tcp_chr_connect(chr); |
|
2166 |
|
|
2167 |
return 0; |
|
2168 |
} |
|
2169 |
|
|
2149 | 2170 |
static void tcp_chr_accept(void *opaque) |
2150 | 2171 |
{ |
2151 | 2172 |
CharDriverState *chr = opaque; |
... | ... | |
2178 | 2199 |
break; |
2179 | 2200 |
} |
2180 | 2201 |
} |
2181 |
socket_set_nonblock(fd); |
|
2182 |
if (s->do_nodelay) |
|
2183 |
socket_set_nodelay(fd); |
|
2184 |
s->fd = fd; |
|
2185 |
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL); |
|
2186 |
tcp_chr_connect(chr); |
|
2202 |
if (tcp_chr_add_client(chr, fd) < 0) |
|
2203 |
close(fd); |
|
2187 | 2204 |
} |
2188 | 2205 |
|
2189 | 2206 |
static void tcp_chr_close(CharDriverState *chr) |
... | ... | |
2256 | 2273 |
chr->chr_write = tcp_chr_write; |
2257 | 2274 |
chr->chr_close = tcp_chr_close; |
2258 | 2275 |
chr->get_msgfd = tcp_get_msgfd; |
2276 |
chr->chr_add_client = tcp_chr_add_client; |
|
2259 | 2277 |
|
2260 | 2278 |
if (is_listen) { |
2261 | 2279 |
s->listen_fd = fd; |
Also available in: Unified diff