Commit Graph

2770 Commits

Author SHA1 Message Date
Frediano Ziglio
a7b0162015 dc: convert break to continue
Both jump to check worker_ring_item (internal or external loops)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
5fbac6c8cb dc: use while again
Convert from for(;;) { if () break; ... } to while

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
0010656ea4 dc: if link is NULL jumping outside loop will check variable and exit
The outer loop will exit too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
9a85e3cf34 dc: if dpi is not NULL even dpi_ring_item is not NULL
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
643bf445c5 dc: dpi is always a value computed from dpi_ring_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
dec4b7eca5 dc: move code inside if
these lines are only executed then the condition are satisfied

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
7447a9e66c dc: dcc used is always a value from current link
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
a3ad49b326 dc: link is never null here
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
1d39275c3d dc: the link condition make this case terminate loop
dpi_ring_item is changed but ignored

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
a5a9b38f46 dc: split if
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
2d4e1e5e0a dc: convert to infinite loop
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-25 14:44:02 +01:00
Frediano Ziglio
091d6400e4 style: Add some abbreviations
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-25 14:43:03 +01:00
Frediano Ziglio
4e7572b41d style: Sort abbreviations alphabetically
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-25 14:42:57 +01:00
Frediano Ziglio
2cb8b1cc9f Removed unused GET_CODE definition
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-25 14:32:42 +01:00
Frediano Ziglio
727d808332 Remove potentially unsafe casts
The id type is already uint64_t, no need to cast using some low
level casts.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-25 09:54:03 +01:00
Frediano Ziglio
b921e81f76 Remove unused macro definitions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-25 09:54:03 +01:00
Frediano Ziglio
6ab857b45c Move RedCacheItem size field inside cache_data union
This reduce a bit the structure size and make clear that
the field is used only when the item is a cache item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-25 09:53:57 +01:00
Frediano Ziglio
68d5ca29f8 Remove not necessary inval_type from RedCacheItem
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-25 09:53:13 +01:00
Jonathon Jongsma
7a51188891 Fix build warning when RED_WORKER_STAT is undefined
since display_channel_print_stats is now static, the compiler complains
when RED_WORKER_STAT is undefined since this function is not used:

    ../../server/display-channel.c:853:13: error: 'display_channel_print_stats' defined but not used [-Werror=unused-function]

To fix, don't define the function when RED_WORKER_STAT is undefined.
Acked-by: Victor Toso <victortoso@redhat.com>
2016-05-25 09:26:10 +02:00
Jonathon Jongsma
a31efd7e75 RedChannel: Add FOREACH_CLIENT and use it to iterate
Remove the custom FOREACH_DCC macro and use the more generic
FOREACH_CLIENT macro and use it for all channels.
2016-05-24 14:56:45 -05:00
Jonathon Jongsma
4028fb1c79 Replace RedChannel::clients with GList
Instead of using a Ring, use a GList to store the list of channel
clients. This allows us to iterate the clients without poking inside of
the client struct to get the channel_link. This is required in order to
make the RedChannelClient struct private.
2016-05-24 14:56:45 -05:00
Jonathon Jongsma
6c4e86cbe3 Move InputsChannelClient to a separate file
Preparation for converting to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-24 14:56:41 -05:00
Frediano Ziglio
dbb6e71e8d change main_channel_marshall_mouse_mode call style
Make the call more similar to other marshall function calls in the
same function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-24 13:44:01 -05:00
Frediano Ziglio
e4a6a1477e move all item creation in main-channel-client.c
Move all core to create and destroy MainChannel pipe items in a single
place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-24 13:41:08 -05:00
Frediano Ziglio
02adcf354e Introduce SPICE_UPCAST macro
This was proposed by Christophe as improvement over some typesafe
patches.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-24 18:00:51 +01:00
Jonathon Jongsma
0528c0877c cache-item.h: remove unnecessary channel include
It's only necessary to include red-pipe-item.h

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-24 17:53:22 +01:00
Jonathon Jongsma
5c64e01111 AgentMsgFilter: use typedef
Instead of using the full 'struct AgentMsgFilter', use the typedef name

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-24 17:46:05 +01:00
Frediano Ziglio
8782bb3211 Make some function static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-24 13:39:48 +01:00
Frediano Ziglio
70f04bdab3 Get code more typesafe
Scan remaining code searching for problems with structure
layout assumptions in the code.
Where code required some restructuring put some verify checks
to make sure code won't compile if these assumptions are not
in place anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:14:13 +01:00
Frediano Ziglio
fb655ff481 reduce casts to RedPipeItem and RingItem
Make code more type safe. This allow to move or delete structure
fields more safely

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
e8a9d3f2b9 rename RedVDIReadBug::parent to base
All other classes using RedPipeItem as base use base as parent name

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
ab69c3367f make red_pipe_item_unref more typesafe
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
f75b69fdc8 make red_pipe_item_ref more typesafe
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
8d764488ca make red_pipe_item_init_full more typesafe
Use a proper type for free callback

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
e960e00392 Use a marker instead of checking a RedPipeItem presence
This avoids having to retain a pointer just to check item is still in
the queue with ring_item_is_linked(&item->link).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
f12464b2f1 Call dcc_send_item directly
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
27145ed9aa Handle reference for RedPipeItem in RedChannel
Remove the need to release the item inside send_item callbacks.
This looks like a partial rollback of previous patch but is
to make clear the intention of the change.
The lifetime of items could extend a bit further but there
are no cases this small lag should cause problems.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
138a11a163 Remove RedChannel::hold_item callback
This is quite confusing and prone to errors.
Use RedPipeItem reference counting instead.
To compensate for the additional reference due to red_pipe_item_ref
in RedChannel sub class with empty hold_item have to add a
red_pipe_item_unref call in send_item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Jonathon Jongsma
17526096aa Remove 'peer' from name of channel client methods
There is some inconsistent naming of RedChannelClient methods. Some
include the word 'peer' (which normally seems to refer to RedsStream).
Remove the 'peer' terminology from those functions that are basically
RedChannelClient methods.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-20 16:12:09 -05:00
Frediano Ziglio
c037c779df let compiler manage the copy in a more typesafe way
Do not use memcpy but just copy the data

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-20 09:17:11 -05:00
Jonathon Jongsma
a11b785f19 Move MainChannelClient to separate file
Preparation for converting to GObject

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-05-20 09:16:47 -05:00
Uri Lublin
b028c2e38a glz: simplification of do_match and PIXEL_ID
Following commit e8017dd366 here
are some more ifdef simplification.

For PIXEL_ID and PIXEL_DIST macros,
the ifndef LZ_PLT defines are special cases of the LZ_PLT
(#else) defines, when pix_per_byte is 1

Now do_match can accept pix_per_byte param for all different
definitions (implementations).

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-05-20 11:46:30 +01:00
Frediano Ziglio
79292edd56 Fix typo in comment
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-05-20 05:53:57 +01:00
Frediano Ziglio
a3c0859122 style: Add an abbreviation
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
2016-05-20 05:53:57 +01:00
Jonathon Jongsma
f7a17f81ea Add red_client_seamless_migration_done_for_channel()
This is a public RedClient API that handles updating itself rather than
having the RedChannelClient poke around at the internal structure in
rec_channel_client_seamless_migration_done().
2016-05-19 14:27:36 -05:00
Jonathon Jongsma
2e326085ad Simplify DisplayChannel hold_item()
Since all pipe items implement refcounting now, just call
red_pipe_item_ref() and eliminate the switch statement.
2016-05-19 14:04:57 -05:00
Jonathon Jongsma
6b0eabc903 Remove unnecessary cursor_pipe_item_ref()
Use the base red_pipe_item_ref() instead of adding an additional static
wrapper function.
2016-05-19 13:54:14 -05:00
Frediano Ziglio
1be06f188e make spice-server-replay use dynamic spice-server library
spice-server-replay is built with the same settings as tests.
Currently the tests links to a convenience spice-server library.
A convenience library is a static library build with object file
for a dynamic library.
This make all tests contain all spice-server library code and not
linking to the spice-server dynamic library (the .so).
It's not a problem for most tests however this make impossible for
spice-server-replay utility to be used with a dynamic spice-server
library (you have to recompile it including the library).
This is a pity as you could for instance compare your system
library behavior with the library you are developing.
Also if we decide to install in a future the utility for testing
we would have lot of code duplication.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:57:06 +01:00
Frediano Ziglio
fa0c32f120 remove a warning building a test
With my compile switches (which are mostly derived from RedHat spec
file) I'm getting this warning:

stream-test.c: In function 'sock_fd_read':
stream-test.c:66:43: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
             *fd = *((int *) CMSG_DATA(cmsg));
                                           ^

memcpy could decrease performance but as this is a test it's not
an issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-18 14:52:10 +01:00
Frediano Ziglio
fb10f5bf52 Simplify #ifdef/#endif in glz code
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00