Commit Graph

60 Commits

Author SHA1 Message Date
Christophe Fergeau
e17767e892 add missing static 2011-05-03 14:44:11 +02:00
Christophe Fergeau
78c1465ed3 add #include <config.h> to all source files
When using config.h, it must be the very first include in all source
files since it contains #define that may change the compilation process
(eg libc structure layout changes when it's used to enable large file
support on 32 bit x86 archs). This commit adds it at the beginning
of all .c and .cpp files
2011-05-03 14:44:10 +02:00
Marc-André Lureau
28f3007145 Revert "server/red_channel: red_channel_event: push on blocked"
This reverts commit 5062433d8a.

red_channel_receive() can call red_channel_destroy() which frees
channel.

The condition bellow is then checked, which can access a freed
channel:

if (event & SPICE_WATCH_EVENT_WRITE || channel->send_data.blocked)

Reverting this commit solves the issue without any apparent
bugs/drawbacks, which kind of clears out the weird TODO.

handle_dev_input: cursor connect
==11826== Invalid read of size 4
==11826==    at 0x4C6F83C: red_channel_event (red_channel.c:535)
==11826==    by 0x41CB8C: main_loop_wait (vl.c:1365)
==11826==    by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589)
==11826==    by 0x41FE9A: main (vl.c:1411)
==11826==  Address 0x31fb00f0 is 96 bytes inside a block of size 28,648 free'd
==11826==    at 0x4A05372: free (vg_replace_malloc.c:366)
==11826==    by 0x4C6F536: red_channel_destroy (red_channel.c:453)
==11826==    by 0x4C52B5D: inputs_channel_on_incoming_error (inputs_channel.c:449)
==11826==    by 0x4C6ED0E: red_channel_peer_on_incoming_error (red_channel.c:215)
==11826==    by 0x4C6E731: red_peer_handle_incoming (red_channel.c:87)
==11826==    by 0x4C6EA55: red_channel_receive (red_channel.c:154)
==11826==    by 0x4C6F82D: red_channel_event (red_channel.c:530)
==11826==    by 0x41CB8C: main_loop_wait (vl.c:1365)
==11826==    by 0x437CDE: kvm_main_loop (qemu-kvm.c:1589)
==11826==    by 0x41FE9A: main (vl.c:1411)
==11826==

https://bugs.freedesktop.org/show_bug.cgi?id=34971
2011-03-03 14:59:31 +01:00
Alon Levy
c771182274 server/red_channel: move out_bytes_counter from Outgoing to RedChannel 2011-03-02 17:27:53 +02:00
Alon Levy
692b41f946 server/red_channel: split Incoming/Outgoing to callback and state
This allows later to have the callback table under RedChannel when
the callbacks actually get used by RedChannelClient. Since the cb's
are identical for different clients of the same channel it makes sense
to store the callback pointers in one place per channel. The rest of
the incoming and outgoing struct just gets moved to RedChannelClient.
2011-03-02 17:27:53 +02:00
Alon Levy
d1feaeb282 server/red_channel: no opaque in red_channel_peer_on_*_error 2011-03-02 17:27:53 +02:00
Alon Levy
7890b623b5 server/red_channel: add red_channel_disconnect, use in red_worker
replace channel_release_res in red_worker with red_channel_disconnect.
2011-03-02 17:27:53 +02:00
Alon Levy
aa5d23fdec server/red_channel: reset send_data.item to NULL after release 2011-03-02 17:27:53 +02:00
Alon Levy
5575d6e5fa server/red_channel: add red_channel_{,no_}item_being_sent 2011-03-02 17:27:53 +02:00
Alon Levy
88db43879b server/red_channel: add red_channel_send_message_pending 2011-03-02 17:27:52 +02:00
Alon Levy
7a650e9641 server/red_channel: add red_channel_all_blocked 2011-03-02 17:27:52 +02:00
Alon Levy
e9be6ca82c server/red_channel (all): add red_channel_get_header
This is useful during the channel specific channel_send_pipe_item_proc
callback, it allows altering or reader the header being sent.
2011-03-02 17:27:52 +02:00
Alon Levy
17d5761322 server/red_channel: add red_channel_get_first_socket
Use in main_channel. This is just for backward portability later
when multiple clients are introduced - needs to be considered (which
sockets do we want to export from libspiceserver?)
2011-03-02 17:27:52 +02:00
Alon Levy
8cd5568c92 server/red_channel (+): remove red_channel_add_buf 2011-03-02 17:27:52 +02:00
Alon Levy
a05628bf06 server/red_channel (all): add red_channel_get_stream
use in config_socket, this makes the stream internal to the RedChannel
implementation that will change later for multiple client support.
2011-03-02 17:27:52 +02:00
Alon Levy
ce03dcfbb5 server/red_channel (all): handle MIGRATE_DATA and MIGRATE_FLUSH_DATA
Handling done in red_channel instead of per channel, using call backs
for the channel specific part.
Intended to reduce furthur reliance of channels on RedChannel struct.

The commit makes the code harder to understand because of the artificial
get_serial stuff, should later be fixed by having a joint migration
header with the serial (since all channels pass it).
2011-03-02 17:27:51 +02:00
Alon Levy
8002a30f9c server/red_channel (all): add red_channel_get_marshaller
For ussage in the send_item callback. It's only valid during this
time anyway (should make it return NULL in other occasions?)

No more direct usage of RedChannel.send_data.marshaller by channels.
2011-03-02 17:27:51 +02:00
Alon Levy
5e1ba1101b server/red_channel: move SET_ACK to red_channel 2011-03-02 17:27:51 +02:00
Alon Levy
2fcd35b073 server/red_channel: add more ack api 2011-03-02 17:27:51 +02:00
Alon Levy
17b6a58f1e server/red_channel (all): makes red_channel_reset_send_data private
ready the way for handling ack messages in RedChannel.
2011-03-02 17:27:51 +02:00
Alon Levy
ce3efca360 server/red_channe: make hold_item take a channel arg 2011-03-02 17:27:50 +02:00
Marc-André Lureau
76dc27f08a server: rename s/peer/stream
This is stylish change again. We are talking about a RedStream object,
so let's just name the variable "stream" everywhere, to avoid
confusion with a non existent RedPeer object.

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:35 +01:00
Marc-André Lureau
fc5d7f7625 server: use the new reds_stream_{read,write}
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-28 16:36:28 +01:00
Marc-André Lureau
07d6dd6108 server: use reds_{link,stream}_free()
Be carefull removing the watch before, like __release_link

https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:19 +01:00
Marc-André Lureau
b79e7320de server: add reds_stream_{read,write,free,remove_watch}()
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 18:26:15 +01:00
Marc-André Lureau
d47912241f server: s/RedsStreamContext/RedsStream
https://bugs.freedesktop.org/show_bug.cgi?id=34795
2011-02-27 16:55:22 +01:00
Alon Levy
8c17f83940 server/red_channel: style fix in red_channel_init_send_data 2011-02-07 19:22:44 +02:00
Alon Levy
c4d028510d server/red_channel: red_channel_pipe_clear: assert on NULL channel 2011-02-07 19:22:44 +02:00
Alon Levy
e9103c67ad server/red_channel: add TODO 2011-02-07 19:22:44 +02:00
Alon Levy
e655c5d26e server/red_channel: export red_channel_send 2011-02-07 19:22:44 +02:00
Alon Levy
10692e20ca server/red_channel: add red_channel_waiting_for_ack
small inline function to have the ack window logic.
2011-02-07 19:22:44 +02:00
Alon Levy
f45d17d68b server/red_channel: protect red_channel_push from NULL 2011-02-07 19:22:44 +02:00
Alon Levy
3476fe428d server/red_channel: reset pipe_size on clear (from red_worker) 2011-02-07 19:22:44 +02:00
Alon Levy
5062433d8a server/red_channel: red_channel_event: push on blocked
try to push either on signal (write available) or when blocked
and read signaled. From red_worker, copied for compatibility when
switching later to RedChannel in red_worker. Doesn't make a lot of
sense (but works), see comment in patch.
2011-02-07 19:22:44 +02:00
Alon Levy
23f13aa983 server/red_channel: use red_channel_receive 2011-02-07 19:22:44 +02:00
Alon Levy
a5afee2842 server/red_channel: add empty handle of SPICE_MSGC_DISCONNECTING
Simply ignored in red_channel_handle_message
2011-02-07 19:22:44 +02:00
Alon Levy
74d7405493 server/red_channel: add red_channel_receive (for red_worker) 2011-02-07 19:22:44 +02:00
Alon Levy
c0b7abaa48 server/red_channel: unstatic red_channel_pipe_clear (for red_worker) 2011-02-07 19:22:44 +02:00
Alon Levy
a30a602654 server/red_channel: unstatic red_channel_push (for red_worker) 2011-02-07 19:22:44 +02:00
Alon Levy
57b719b991 server/red_channel: two 80 column fixes 2011-02-07 19:22:44 +02:00
Alon Levy
33bede823a server/red_channel: add public red_channel_default_peer_on_error
for later use in red_worker
2011-02-07 19:22:44 +02:00
Alon Levy
c322873cf0 server/red_channel: add red_channel_pipe_add_after (from red_worker) 2011-02-07 19:22:44 +02:00
Alon Levy
23f37df548 server/red_channel: make client ack window configurable
from red_worker
2011-02-07 19:22:44 +02:00
Alon Levy
0512726b68 server/red_channel (tunnel): change sig of red_channel_handle_message
for later usage with red_worker
2011-02-07 19:22:44 +02:00
Alon Levy
194a6be5f7 server/red_channel: add red_channel_pipe_add_push 2011-02-07 19:22:44 +02:00
Alon Levy
7dfd7a0c77 server/red_channel: add hold_item (from red_worker)
hold_item called on init_send_data, matching release.
This is not the behavior of red_worker - we ref++ (==hold_item) when
sending the item, and --refs when releasing it, instead of only holding
if the send is blocked.

Note 1: Naming: hold_pipe_item is the proc name, the variable is called
hold_item, this is similar to release_item/release_pipe_item naming.

Note 2: All channels have empty implementation, we later use this when
red_worker get's RedChannelized.
2011-02-07 19:21:21 +02:00
Alon Levy
e571b5ebbb server/red_channel: add out_bytes_counter (unused) 2011-02-07 19:06:52 +02:00
Alon Levy
f16c2fccdd server/red_channel: fix segfault on red_channel_destroy if peer already removed 2011-01-16 11:59:08 +02:00
Alon Levy
444b322cab server/red_channel: no need for extra loop 2011-01-15 20:54:48 +02:00
Alon Levy
90c93eb3c1 server/red_channel: go marshaller for outgoing (copied from red_worker) 2011-01-13 06:56:54 +02:00