summaryrefslogtreecommitdiffstats
path: root/server/red_worker.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Mark functions which never return controlDaniel P. Berrange2012-04-251-3/+2
| | | | | | | | * client/red_channel.cpp: AbortTrigger::on_event can't return given its current impl * server/red_worker.c: red_worker_main can't return Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Fix multiple printf format problemsDaniel P. Berrange2012-04-251-6/+6
| | | | | | | | | | | | | | | | All printf var-args style methods should be annotation with their format. All format strings must be const strings. * client/application.cpp, client/cmd_line_parser.cpp, client/hot_keys.cpp: Avoid non-const format * client/client_net_socket.cpp: Fix broken format specifier * client/red_peer.cpp: Fix missing format specifier * client/platform.h: Add SPICE_GNUC_PRINTF annotation to term_printf * client/utils.h: Add SPICE_GNUC_PRINTF annotation to string_printf * server/glz_encoder_config.h, server/red_worker.c: Add SPICE_GNUC_PRINTF annotation to warning callbacks Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* Fix const-ness violationsDaniel P. Berrange2012-04-251-1/+1
| | | | | | | * server/red_worker.c: Add missing const for return type * server/reds.c: Static strings must be declared const Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* server: allow failure in getvirtAlon Levy2012-04-051-14/+33
| | | | | | | This patch changed getvirt to continue working even if spice_critical doesn't abort (i.e. SPICE_ABORT_LEVEL != -1). This is in preparation to make getvirt not abort at all. The reason is that getvirt is run on guest provided memory, so a bad driver can crash the vm.
* Use the spice-common logging functionsMarc-André Lureau2012-03-251-298/+304
| | | | | It will abort by default for critical level messages. That behaviour can be tuned at runtime.
* Use the spice-common submoduleMarc-André Lureau2012-03-251-12/+14
| | | | | | | | | | | | | | | | | | This patch will replace the common/ directory with the spice-common project. It is for now a simple project subdirectory shared with spice-gtk, but the goal is to make it a proper library later on. With this change, the spice-server build is broken. The following commits fix the build, and have been seperated to ease the review. v2 - moves all the generated marshallers to spice-common library - don't attempt to fix windows VS build, which should somehow be splitted with spice-common (or built from tarball only to avoid generation tools/libs deps) v3 - uses libspice-common-client - fix a mutex.h inclusion reported by Alon
* server/red_worker: fix for case where ASSERT is compiled outAlon Levy2012-03-211-2/+1
|
* server/red_worker: don't typedef SpiceWatch twiceAlon Levy2012-03-201-2/+2
| | | | First defined in spice.h, fixes build failure with gcc 4.4.6
* red_worker: Check for NULL watchesHans de Goede2012-03-131-2/+13
| | | | | | | | If we run out of watches slots, we return NULL from watch_add, which means that the other watch_foo functions may get called with a NULL parameter, protect them against this. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* red_worker: Rework poll code to use the watch interfaceHans de Goede2012-03-121-91/+79
| | | | | | | | | | | | | | | | | | | | | | | | | Commit 143a1df24e83e9c1e173c16aeb76d61ffdce9598 changed red_worker_main from epoll to poll. But epoll has edge triggered semantics (when requested and we requested them), where as poll is always level triggered. And red_worker was relying on the edge triggered semantics, as it was always polling for POLLOUT, which, when edge triggered, would only cause poll to register an event after we had blocked on a write. But after the switch to regular poll, with its level triggered semantics, the POLLOUT condition would almost always be true, causing red_worker_main to not block on the poll and burn CPU as fast as it can as soon as a client was connected. Luckily we already have a mechanism to switch from polling for read only to polling for read+write and back again in the form of watches. So this patch changes the red_worker dummy watch implementation into a proper watch implementation, and drops the entire EventListener concept since that then is no longer needed. This fixes spice-server using 400% CPU on my quad core machine as soon as a client was connected to a multi head vm, and as an added bonus is a nice cleanup IMHO. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* red_worker: Remove ref counting from the EventListener structHans de Goede2012-03-101-34/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The red_worker EventListener struct is either embedded in one of: 1) DisplayChannelClient 2) CursorChannelClient 3) RedWorker And as such gets destroyed when these get destroyed, in case 1 & 2 through a call to red_channel_client_destroy(). So free-ing it when the ref-count becomes 0 is wrong, for cases: 1) and 2) this will lead to a double free; 3) this will lead to passing memory to free which was not returned by malloc. This is not causing any issues as the ref-count never gets decremented, other then in red_worker_main where it gets incremented before it gets decremented, so it never becomes 0. So we might just as well completely remove it. Notes: 1) This is mainly a preparation patch for fixing issues introduced by the move from epoll to poll 2) Since removing the ref-counting removes the one code path where listeners would get set to NULL, this patch moves the setting of NULL to pre_disconnect, where it should have been done in the first place since red_client_destroy calls red_channel_client_disconnect (through the dispatcher) followed by red_channel_client_destroy, so after pre_disconnect the listener may be gone. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Ensure all members of ChannelCbs and ClientCbs are either assigned or NULLHans de Goede2012-03-101-1/+1
| | | | | | | | | | | | | | | While git-bisecting another issue I ended up hitting and not recognizing the bug fixed by commit 7a079b452b026d6ce38f95dcc397fa64b059fffb. While fixing this (again) I noticed that (even after the fix) not all users of ChannelCbs first zero it. So this patch ensures that all users of ChannelCbs first zero it, and does the same for ClientCbs while at it. Since before this patch there were multiple zero-ing styles, some using memset and other using a zero initializer this patch also unifies all the zero-ing to use a NULL initializer for the first element. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* server/red_worker: fix use after free for listenersAlon Levy2012-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a core dumped observed once by repeated migration. So far 100 migrations and no recurrence. Core was generated by `/home/alon/spice/upstream/bin/qemu-system-x86_64 --enable-kvm -qmp unix:/tmp/mi'. Program terminated with signal 11, Segmentation fault. 11197 if (evt_listener && evt_listener->refs > 1) { Missing separate debuginfos, use: debuginfo-install bluez-libs-4.98-3.fc17.x86_64 brlapi-0.5.6-4.fc17.x86_64 bzip2-libs-1.0.6-4.fc17.x86_64 cryptopp-5.6.1-6.fc17.x86_64 keyutils-libs-1.5.5-2.fc17.x86_64 libssh2-1.4.0-1.fc17.x86_64 nss-softokn-freebl-3.13.1-20.fc17.x86_64 xen-libs-4.1.2-11.fc17.x86_64 xz-libs-5.1.1-2alpha.fc17.x86_64 (gdb) bt (gdb) l 11192 for (i = 0; i < MAX_EVENT_SOURCES; i++) { 11193 struct pollfd *pfd = worker.poll_fds + i; 11194 if (pfd->revents) { 11195 EventListener *evt_listener = worker.listeners[i]; 11196 11197 if (evt_listener && evt_listener->refs > 1) { 11198 evt_listener->action(evt_listener, pfd); 11199 if (--evt_listener->refs) { 11200 continue; 11201 } (gdb) p evt_listener $1 = (EventListener *) 0x7f15a9a5d1e0 (gdb) p *evt_listener Cannot access memory at address 0x7f15a9a5d1e0 (gdb) p i $2 = 2 (gdb) p worker.listeners $3 = {0x7f15bc832520, 0x7f15a406e1a0, 0x7f15a9a5d1e0, 0x0 <repeats 17 times>}
* red_worker: reimplement event loop using poll()Dan McGee2012-02-211-42/+64
| | | | | | | | | | | | | | | | | | This removes the epoll dependency we had in red_worker, which was the last Linux-specific call we were using in the entire Spice server. Given we never have more than 10 file descriptors involved, there is little performance gain had here by using epoll() over poll(). The biggest change is introduction of a new pre_disconnect callback; this is because poll, unlike epoll, cannot automatically remove file descriptors as they are closed from the pollfd set. This cannot be done in the existing on_disconnect callback; that is too late as the stream has already been closed and the file descriptor lost. The on_disconnect callback can not be moved before the close and other operations easily because of some behavior that relies on client_num being set to a certain value. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Cleanup definitions of disconnect methodsDan McGee2012-02-211-21/+5
| | | | | | | | | We had multiple stub methods that simply called other disconnect methods, making my head hurt with the indirection. Call the right methods at the right time and rip out the stub methods; if they are truely needed later they can be added again. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* red_worker: rename epoll_timeout to event_timeoutDan McGee2012-02-211-10/+11
| | | | | | | | | With future patches in mind that will allow for some other non-Linux-specific event polling sytem to be used, rename this to a more generic name. All of the select/poll/epoll/kqueue family of calls are related to evented I/O, so 'event_' makes sense in this case. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Remove extra '\n' from red_printf() callsDan McGee2012-02-141-1/+1
| | | | | | | red_printf() takes care of adding a newline to all messages; remove the extra newline from all messages and macros that were doubling them up. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Fix git commit hook errors in red_workerDan McGee2012-01-231-32/+56
| | | | | | | This ensures all line lengths are down below 100 characters as well as removing some trailing spaces. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* server: Don't complain if setsockopt NODELAY fails on unix socketsHans de Goede2012-01-181-1/+3
| | | | | | | | | | | | With Daniel P. Berrange's patches to allow use of pre-supplied fd's as channels, we can no longer be sure that our connections are TCP sockets, so it makes no sense to complain if a TCP/IP specific setsockopt fails with an errno of ENOTSUP. Note that this extends Daniel's commit 492ddb5d1d595e2d12208f4602b18e4432f4e6b4 which already added the same check to server/inputs_channel.c Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Remove trailing whitespace from end of linesDaniel P. Berrange2012-01-131-1/+1
|
* Remove useless if() before free()Daniel P. Berrange2012-01-131-3/+1
| | | | | The free() function allows NULL to be passed in, so any code which puts a if() before free() is wasting time
* Death to all TABsDaniel P. Berrange2012-01-131-1/+1
| | | | | | Source files should all use spaces instead of tabs for indentation. Update the few files not already in compliance
* server: add support for SPICE_COMMON_CAP_MINI_HEADERYonit Halperin2012-01-121-33/+125
| | | | | | | | | Support for a header without a serial and without sub list. red_channel: Support the two types of headers. Keep a consistent consecutive messages serial. red_worker: use urgent marshaller instead of sub list. snd_worker: Sound channels need special support since they still don't use red_channel for sending & receiving.
* server: Limit the access to SpiceDataHeader of messages - only via red_channel.Yonit Halperin2012-01-121-5/+4
|
* server/red_worker: pass remote caps to display/cursor red_channel_client'sYonit Halperin2012-01-121-12/+44
|
* server: don't reset the display channel when disconnecting all its clients ↵Yonit Halperin2011-12-221-12/+6
| | | | | | | | | | | | ,FDBZ #43977 The display channel was unnecessarily set to NULL when we disconnect all the clients (on flush display commands timeout). As a result, we recreated the display channel when a new client was connected. The display channel was created with default red_channel.client_cbs, while its correct client_cbs are the ones that are set by the red_dispatcher when it creates the first display_channel. This fix enforces a single creation of the display channel (per qxl), via the red_dispatcher.
* server/red_worker: reuse dispatcherAlon Levy2011-11-081-334/+569
| | | | | | | | | | | | | | | | | | | | | | This patch reuses Dispatcher in RedDispatcher. It adds two helpers to red_worker to keep RedWorker opaque to the outside. The dispatcher is abused in three places that use the underlying socket directly: once sending a READY after red_init completes once for each channel creation, replying with the RedChannel instance for cursor and display. FDO Bugzilla: 42463 rfc->v1: * move callbacks to red_worker.c including registration (Yonit) * rename dispatcher to red_dispatcher in red_worker.c and red_dispatcher.c * add accessor red_dispatcher_get_dispatcher * s/dispatcher_handle_recv/dispatcher_handle_recv_read/ and change sig to just Dispatcher *dispatcher (was the SpiceCoreInterface one) * remove SpiceCoreInterface parameter from dispatcher_init (Yonit) * main_dispatcher needed it for channel_event so it has it in struct MainDispatcher * add dispatcher_get_recv_fd for red_worker
* server: add prefix argument to red_printf_debugAlon Levy2011-11-071-8/+10
| | | | | printed before function name. No central location for prefixes. Adding "WORKER", "ASYNC", "MAIN" since those were the current users.
* server/red_dispatcher: support concurrent asyncsAlon Levy2011-11-071-3/+3
| | | | | | | | | | | | | | | This is part of the dispatcher update, extracting the dispatcher routine from red_dispatcher and main_dispatcher into dispatcher. Supporting multiple async operations will make it natural to support async monitor commands and async guest io requests that could overlap in time. Use a Ring for AsyncCommands. Free Desktop Bugzilla: 42463 Related FD: 41622
* server: set & test channel capabilities in red_channelYonit Halperin2011-11-021-1/+2
| | | | | | | The code for setting and testing channel capabilities was unnecessarily duplicated. Now it is in red_channel. RedsChannel was dropped from Reds; It was used only for holding the channels common capabilities, which are now held in RedChannel.
* server/red_worker: fix placing of ↵Yonit Halperin2011-10-181-4/+6
| | | | | | | ASSERT(red_channel_client_no_item_being_sent) (fdbz #41523) Call ASSERT(red_channel_client_no_item_being_sent) only if red_wait_outgoing_item/s did not timeout.
* replace warning with comment in glz_usr_free_imageChristophe Fergeau2011-09-191-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running some xinerama tests, I got several glz_usr_free_image: error messages. Looking at the code, this error is reported when this function is called from a different DisplayChannelClient than the one which created the glz compressed image. When this happens, the backtrace is at glz_encoder_dictionary.c:362 0x7fff940b6670) at glz_encoder_dictionary.c:449 image_type=LZ_IMAGE_TYPE_RGB32, image_width=512, image_height=256, image_stride=2048, first_lines=0x0, num_first_lines=0, usr_image_context=0x7fff7420da40, image_head_dist=0x7fff9b2a3194) at glz_encoder_dictionary.c:570 top_down=4, lines=0x0, num_lines=0, stride=2048, io_ptr=0x7fff740ea7c0 " ZL", num_io_bytes=65536, usr_context= 0x7fff7420da40, o_enc_dict_context=0x7fff7420da60) at glz_encoder.c:255 drawable=0x7fff9b46bc08, o_comp_data=0x7fff9b2a3350) at red_worker.c:5753 0x7fff9b46bc08, can_lossy=0, o_comp_data=0x7fff9b2a3350) at red_worker.c:6211 0x7fff9b46bc08, can_lossy=0) at red_worker.c:6344 0x7fff74085c50, dpi=0x7fff7445b890, src_allowed_lossy=0) at red_worker.c:7046 0x7fff7445b890) at red_worker.c:7720 at red_worker.c:7964 at red_worker.c:8431 Since the glz dictionary is shared between all the DisplayChannelClient instances that belong to the same client, it can happen that the glz dictionary code decides to free an image from one thread while it was added from another thread (thread == DisplayChannelClient), so the error message that is printed is not an actual error. This commit removes this message and adds a comment explaining what's going on.
* server: fix function prototypesChristophe Fergeau2011-09-051-1/+1
| | | | | | | | Several functions in server/ were not specifying an argument list, ie they were declared as void foo(); When compiling with -Wstrict-prototypes, this leads to: test_playback.c:93:5: erreur: function declaration isn’t a prototype [-Werror=strict-prototypes]
* server: init all fields on SpiceMsgDisplayStreamCreateChristophe Fergeau2011-09-011-0/+2
| | | | | | | | | red_display_marshall_stream_start initializes a SpiceMsgDisplayStreamCreate structure before marshalling it and sending it on the wire. However, it never fills SpiceMsgDisplayStreamCreate::stamp which then causes a complaint from valgrind. This patch sets this value to 0, it's not used by the client so the value shouldn't matter.
* drawables count for debugYonit Halperin2011-08-231-10/+32
|
* server: registering RedChannel in reds, instead of ChannelYonit Halperin2011-08-231-98/+81
| | | | | | | | | | | | | | | | | | | | | | | Merging the functionality of reds::channel, into RedChannel. In addition, cleanup and fix disconnection code: before this patch, red_dispatcher_disconnect_display_client could have been called from the red_worker thread (and it must be called only from the io thread). RedChannel holds only connected channel clients. RedClient holds all the channel clients that were created till it is destroyed (and then it destroys them as well). Note: snd_channel still doesn't use red_channel, however it creates dummy channel and channel clients, in order to register itself in reds. server/red_channel.c: a channel is connected if it holds at least one channel client Previously I changed RedChannel to hold only connected channel clients and RedClient, to hold all the channel clients as long as it is not destroyed. usbredir: multichannel has not been tested, it just compiles.
* server/red_channel.c: pack all channel callbacks to ChannelCbsYonit Halperin2011-08-231-12/+15
|
* server/red_worker: add ref counting to RedDrawableAlon Levy2011-08-231-13/+29
| | | | | | | | introduces ref_red_drawable and put_red_drawable (rename from free_red_drawable) RedDrawable is already references by Drawable and RedGlzDrawable, with a hack to NULL the drawable field in RedGlzDrawable to indicate RedGlzDrawable is the last reference holder. Using an explicit reference count instead.
* server/red_worker: add stream_count (for debug purposes)Alon Levy2011-08-231-0/+3
|
* server/red_worker: validate_surface: print paniced surface_idAlon Levy2011-08-231-1/+4
|
* server/red_worker: no panic on double destroy primaryAlon Levy2011-08-231-1/+5
|
* server/red_worker: DEBUG_CURSORSAlon Levy2011-08-231-0/+13
| | | | | Add cursor allocation debugging code that is turned off as long as DEBUG_CURSORS is not defined.
* server/red_worker: on_new_display_channel_client: push ack, cleanupAlon Levy2011-08-231-4/+3
| | | | small cleanup patch, only functional change is sending a set ack message.
* server/red_worker: add cursor_channel_client_disconnectAlon Levy2011-08-231-1/+10
| | | | | makes RED_WORKER_MESSAGE_CURSOR_DISCONNECT_CLIENT disconnect only a single client.
* server/red_worker: remove forced disconnect on connectAlon Levy2011-08-231-2/+0
|
* server/red_worker.c: fix CursorPipeItem leakYonit Halperin2011-08-231-4/+35
| | | | | | | CursorPipeItems and their corresponding cursor_item were not freed when they were removed from the pipe without sending them. In addition cursor_channel_hold_pipe_item used wrong conversion to (CursorItem*) for a (CursorPipeItem*).
* server/red_worker: split cursor pipe item from cursor itemAlon Levy2011-08-231-26/+34
| | | | | | | | | | Required to support multiple clients. Also changes somewhat the way we produce PIPE_ITEM_TYPE_LOCAL_CURSOR. Btw, I haven't managed to see when we actually produce such an item during my tests. Previously we had a single pipe item per CursorItem, this is impossible with two pipes, which happens when we have two clients.
* server/red_worker: whitespace fixesAlon Levy2011-08-231-2/+1
|
* server/red_channel: introduce client ring in RedChannelAlon Levy2011-08-231-271/+604
| | | | | | | | | | | | | | | | | Also adds Drawable pipes and glz rings. main_channel and red_worker had several locations that still accessed rcc directly, so they had to be touched too, but the changes are minimal. Most changes are in red_channel: drop the single client reference in RedChannel and add a ring of channels. Things missing / not done right in red_worker: * StreamAgents are in DCC - right/wrong? * GlzDict is multiplied - multiple compressions. We still are missing: * remove the disconnect calls on new connections
* server/red_channel: add pipe_size helpersAlon Levy2011-08-231-7/+11
|