Skip to content

Commit 1963523

Browse files
committed
Handle IPC responses on another thread
1 parent 1c4d04f commit 1963523

File tree

11 files changed

+505
-145
lines changed

11 files changed

+505
-145
lines changed

include/ggl/attr.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@
9696
#define NULL_TERMINATED_STRING_ARG(pos)
9797
#endif
9898

99+
#ifdef __has_attribute
100+
#if __has_attribute(access)
101+
#define ACCESS(...) __attribute__((access(__VA_ARGS__)))
102+
#endif
103+
#endif
104+
105+
#ifndef ACCESS
106+
#define ACCESS(...)
107+
#endif
108+
99109
#ifdef __has_attribute
100110
#if __has_attribute(cold)
101111
#define COLD __attribute__((cold))
@@ -116,4 +126,14 @@
116126
#define CONST
117127
#endif
118128

129+
#ifdef __has_attribute
130+
#if __has_attribute(flag_enum)
131+
#define FLAG_ENUM __attribute__((flag_enum))
132+
#endif
133+
#endif
134+
135+
#ifndef FLAG_ENUM
136+
#define FLAG_ENUM
137+
#endif
138+
119139
#endif

include/ggl/error.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ typedef enum NODISCARD GglError {
4343
GGL_ERR_REMOTE,
4444
/// Expected non-ok status
4545
GGL_ERR_EXPECTED,
46+
/// Request timed out
47+
GGL_ERR_TIMEOUT,
4648
} GglError;
4749

4850
const char *ggl_strerror(GglError err);

priv_include/ggl/eventstream/rpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef enum {
2121
} EventStreamMessageType;
2222

2323
/// `:message-flags` header flags
24-
typedef enum {
24+
typedef enum FLAG_ENUM {
2525
EVENTSTREAM_CONNECTION_ACCEPTED = 1,
2626
EVENTSTREAM_TERMINATE_STREAM = 2,
2727
} EventStreamMessageFlags;

priv_include/ggl/ipc/client_priv.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
#include <ggl/buffer.h>
1010
#include <ggl/error.h>
1111

12+
/// Maximum size of eventstream packet.
13+
/// Can be configured with `-D GGL_IPC_MAX_MSG_LEN=<N>`.
14+
#ifndef GGL_IPC_MAX_MSG_LEN
15+
#define GGL_IPC_MAX_MSG_LEN 10000
16+
#endif
17+
18+
/// Maximum size IPC functions will wait for server response
19+
#ifndef GGL_IPC_RESPONSE_TIMEOUT
20+
#define GGL_IPC_RESPONSE_TIMEOUT 10
21+
#endif
22+
1223
/// Connect to GG-IPC server using component name.
1324
/// If svcuid is non-null, it will be filled with the component's identity
1425
/// token. Buffer must be able to hold at least GGL_IPC_SVCUID_STR_LEN.

src/error.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const char *ggl_strerror(GglError err) {
4040
return "REMOTE";
4141
case GGL_ERR_EXPECTED:
4242
return "EXPECTED";
43+
case GGL_ERR_TIMEOUT:
44+
return "TIMEOUT";
4345
}
4446

4547
assert(false);

0 commit comments

Comments
 (0)