Skip to content

Commit

Permalink
(shmif) handover-exec wrong descriptor and poll
Browse files Browse the repository at this point in the history
This should fix the case where the wrong expected dpipe/epipe for
handover-exec inherit shmifsrv. Added an extra client state to
distinguish between idle- and no-frame delivered. Both of these
will be relevant with upcoming net-directory mode changes.
  • Loading branch information
letoram committed Sep 16, 2023
1 parent 1776236 commit bf9861d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/frameserver/util/anet_helper.h
Expand Up @@ -35,6 +35,10 @@ struct anet_options {
* 'default' will be used */
const char* host_tag;

/* petname used to register as a source/linked directory in another - this is a
* hint, the server may well assign a different one */
const char petname[16];

/* pre-inherited socket to use */
int sockfd;

Expand All @@ -51,7 +55,6 @@ struct anet_options {
const char* redirect_exit;

/* similarly, remember any local connection point and use that */

const char* devicehint_cp;

/* allow connection retries, -1 infinite, 0 no retry */
Expand Down
12 changes: 8 additions & 4 deletions src/shmif/arcan_shmif_server.c
Expand Up @@ -179,7 +179,7 @@ struct shmifsrv_client* shmifsrv_spawn_client(
return NULL;
}

*clsocket = res->con->dpipe;
*clsocket = childend;
res->cookie = arcan_shmif_cookie();
res->status = AUTHENTICATING;

Expand Down Expand Up @@ -354,8 +354,10 @@ int shmifsrv_poll(struct shmifsrv_client* cl)
int a = !!(atomic_load(&cl->con->shm.ptr->aready));
int v = !!(atomic_load(&cl->con->shm.ptr->vready));
shmifsrv_leave();
return
(CLIENT_VBUFFER_READY * v) | (CLIENT_ABUFFER_READY * a);
if (a || v)
return
(CLIENT_VBUFFER_READY * v) | (CLIENT_ABUFFER_READY * a);
return CLIENT_IDLE;
}
else
cl->status = BROKEN;
Expand Down Expand Up @@ -598,7 +600,9 @@ bool shmifsrv_tick(struct shmifsrv_client* cl)
return true;
}

static int64_t timebase, c_ticks;
static _Thread_local int64_t timebase;
static _Thread_local int64_t c_ticks;

int shmifsrv_monotonic_tick(int* left)
{
int64_t now = arcan_timemillis();
Expand Down
13 changes: 6 additions & 7 deletions src/shmif/arcan_shmif_server.h
Expand Up @@ -46,6 +46,8 @@ struct shmifsrv_client;
* preroll- event stage.
*/
struct shmifsrv_envp {

int fd_bin;
char* path;
char** argv;
char** envv;
Expand Down Expand Up @@ -188,7 +190,8 @@ enum shmifsrv_client_status {
CLIENT_DEAD = -1,
CLIENT_NOT_READY = 0,
CLIENT_VBUFFER_READY = 1,
CLIENT_ABUFFER_READY = 2
CLIENT_ABUFFER_READY = 2,
CLIENT_IDLE = 3
};
int shmifsrv_poll(struct shmifsrv_client*);

Expand All @@ -197,10 +200,6 @@ int shmifsrv_poll(struct shmifsrv_client*);
* been created through shmifsrv_allocate_connpoint and is still in a listening
* state, the underlying descriptor won't be closed in order for the connpoint
* to be reused.
*
* If [full] is set to false, the client will not be directly told that the
* connection is dead via the normal 'dead-man-switch' handle, only through
* the event-queue - forcing the client to try and use some recovery mechanism.
*/
enum shmifsrv_action {
SHMIFSRV_FREE_FULL = 0,
Expand Down Expand Up @@ -335,7 +334,7 @@ bool shmifsrv_audio(struct shmifsrv_client* cl,
size_t n_samples, unsigned channels, unsigned rate, void* tag), void* tag);

/*
* [THREAD_UNSAFE]
* [THREAD:USES_TLS]
* This is a helper function that returns the number of monotonic ticks
* since the last time this function was called. It is thus a global state
* shared by many clients, along with the optional time to next tick. The
Expand All @@ -351,7 +350,7 @@ bool shmifsrv_audio(struct shmifsrv_client* cl,
int shmifsrv_monotonic_tick(int* left);

/*
* [THREAD_UNSAFE]
* [THREAD:USES_TLS]
* Explicitly rebase the shared clock counter due to a large stall,
* pause, global suspend action and so on.
*/
Expand Down

0 comments on commit bf9861d

Please sign in to comment.