This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gokdrive. commit 76971de4d9a20d36210e56627a912b46148d72c5 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Thu Sep 16 09:52:08 2021 +0200 reiniting of frame and cursors caches by client request. --- debian/changelog | 1 + x2gokdriveremote.c | 45 ++++++++++++++++++++++++++++++++++++++++----- x2gokdriveremote.h | 11 +++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3e17efc..1a4a4b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,7 @@ x2gokdrive (0.0.0.1-0x2go1) UNRELEASED; urgency=medium - fix infinite loop if reading of cookie has failed. - improve initialization of cursor frame and cache element structures. - improve clearing of the frame list. + - reiniting of frame and cursors caches by client request. [ Mihai Moldovan ] * Initial release: diff --git a/x2gokdriveremote.c b/x2gokdriveremote.c index 4125dcd..67df1c3 100644 --- a/x2gokdriveremote.c +++ b/x2gokdriveremote.c @@ -598,6 +598,15 @@ int send_output_selection(struct OutputChunk* chunk) return 0; } +void send_reinit_notification(void) +{ + unsigned char buffer[56] = {0}; + _X_UNUSED int l; + *((uint32_t*)buffer)=REINIT; + EPHYR_DBG("SENDING REINIT NOTIFICATION"); + l=write(remoteVars.clientsock,buffer,56); +} + int send_selection_chunk(int sel, unsigned char* data, uint32_t length, uint32_t format, BOOL first, BOOL last, uint32_t compressed, uint32_t total) { unsigned char buffer[56] = {0}; @@ -1469,7 +1478,8 @@ void *send_frame_thread (void *threadid) - if(!remoteVars.first_sendqueue_element && !remoteVars.firstCursor && !remoteVars.selstruct.firstOutputChunk) + if(!remoteVars.first_sendqueue_element && !remoteVars.firstCursor && !remoteVars.selstruct.firstOutputChunk && + !remoteVars.cache_rebuilt) { /* sleep if frame queue is empty */ pthread_cond_wait(&remoteVars.have_sendqueue_cond, &remoteVars.sendqueue_mutex); @@ -1477,6 +1487,15 @@ void *send_frame_thread (void *threadid) /* mutex is locked on this point */ + //send notification to client that cache is rebuilt + if(remoteVars.cache_rebuilt) + { + remoteVars.cache_rebuilt=FALSE; + pthread_mutex_unlock(&remoteVars.sendqueue_mutex); + send_reinit_notification(); + pthread_mutex_lock(&remoteVars.sendqueue_mutex); + } + //only send output selection chunks if there are no frames and cursors in the queue //selections can take a lot of bandwidth and have less priority if(remoteVars.selstruct.firstOutputChunk && !remoteVars.first_sendqueue_element && !remoteVars.firstCursor) @@ -2342,6 +2361,12 @@ clientReadNotify(int fd, int ready, void *data) //receive keepalive event, don't need to do anything break; } + case CACHEREBUILD: + { + //rebuild all frame and cursors caches + rebuild_caches(); + break; + } default: { EPHYR_DBG("UNSUPPORTED EVENT: %d",event_type); @@ -3305,10 +3330,9 @@ void add_frame(uint32_t width, uint32_t height, int32_t x, int32_t y, uint32_t c pthread_mutex_lock(&remoteVars.sendqueue_mutex); - if(! (remoteVars.client_connected && remoteVars.client_initialized)) + if(! (remoteVars.client_connected && remoteVars.client_initialized) || remoteVars.cache_rebuilt) { - /* don't have any clients connected, return */ - + /* don't have any clients connected, or cache rebuild is requested, return */ pthread_mutex_unlock(&remoteVars.sendqueue_mutex); return; } @@ -3368,7 +3392,6 @@ void add_frame(uint32_t width, uint32_t height, int32_t x, int32_t y, uint32_t c pthread_cond_signal(&remoteVars.have_sendqueue_cond); pthread_mutex_unlock(&remoteVars.sendqueue_mutex); - /* on this point will be sent wakeup single to send mutex */ } @@ -3611,3 +3634,15 @@ remote_screen_init(KdScreenInfo *screen, return remoteVars.main_img; } + +void rebuild_caches(void) +{ + EPHYR_DBG("CLIENT REQUESTED CLEARING ALL CACHES AND QUEUES"); + pthread_mutex_lock(&remoteVars.sendqueue_mutex); + clear_send_queue(); + clear_frame_cache(0); + freeCursors(); + remoteVars.cache_rebuilt=TRUE; + pthread_cond_signal(&remoteVars.have_sendqueue_cond); + pthread_mutex_unlock(&remoteVars.sendqueue_mutex); +} diff --git a/x2gokdriveremote.h b/x2gokdriveremote.h index ce48005..62af332 100644 --- a/x2gokdriveremote.h +++ b/x2gokdriveremote.h @@ -97,7 +97,9 @@ //Changes 1 - 2: supporting extended selection and sending selection on demand //Changes 2 - 3: supporting web client, sending cursors in PNG format and know about KEEPALIVE event //Changes 3 - 4: extended clipboard support for web client -#define FEATURE_VERSION 4 +//Changes 4 - 5: support for CACHEREBUILD event + +#define FEATURE_VERSION 5 #define MAXMSGSIZE 1024*16 @@ -119,7 +121,7 @@ //always 4 #define XSERVERBPP 4 -enum msg_type{FRAME,DELETED, CURSOR, DELETEDCURSOR, SELECTION, SERVERVERSION, DEMANDCLIENTSELECTION}; +enum msg_type{FRAME,DELETED, CURSOR, DELETEDCURSOR, SELECTION, SERVERVERSION, DEMANDCLIENTSELECTION, REINIT}; enum AgentState{STARTING, RUNNING, RESUMING, SUSPENDING, SUSPENDED, TERMINATING, TERMINATED}; enum Compressions{JPEG,PNG}; enum SelectionType{PRIMARY,CLIPBOARD}; @@ -151,6 +153,7 @@ enum OS_VERSION{OS_LINUX, OS_WINDOWS, OS_DARWIN, WEB}; #define CLIENTVERSION 10 #define DEMANDSELECTION 11 #define KEEPALIVE 12 +#define CACHEREBUILD 13 #define EVLENGTH 41 @@ -428,6 +431,9 @@ struct _remoteHostVars BOOL client_connected; BOOL client_initialized; + //if all cache are cleared and notofictaion to client should be send + BOOL cache_rebuilt; + struct SelectionStructure selstruct; } ; @@ -511,5 +517,6 @@ remote_paint_rect(KdScreenInfo *screen, int sx, int sy, int dx, int dy, int width, int height); void request_selection_from_client(enum SelectionType selection); +void rebuild_caches(void); #endif /* X2GOKDRIVE_REMOTE_H */ -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gokdrive.git