File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 25
25
} \
26
26
} while (0);
27
27
28
+ /* Return and error codes. */
29
+
30
+ /* If a fatal error happens, the process exits with an exit code. */
31
+
32
+ #define GIVE_UP (STATUS_CODE ) \
33
+ do { \
34
+ LOG_ERR("Giving up with status code %d", STATUS_CODE); \
35
+ exit(STATUS_CODE); \
36
+ } while (0);
37
+
38
+ /* Unique IDs */
39
+
28
40
#define UNIQUE_ID_SIZE 20
29
41
30
42
typedef struct { unsigned char id [UNIQUE_ID_SIZE ]; } unique_id ;
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ int64_t event_loop_attach(event_loop *loop,
21
21
int type ,
22
22
void * data ,
23
23
int fd ,
24
- int events ) {
24
+ int events_tag ) {
25
25
assert (utarray_len (loop -> items ) == utarray_len (loop -> waiting ));
26
26
int64_t index = utarray_len (loop -> items );
27
27
event_loop_item item = {.type = type , .data = data };
28
28
utarray_push_back (loop -> items , & item );
29
- struct pollfd waiting = {.fd = fd , .events = events };
29
+ struct pollfd waiting = {.fd = fd , .events = events_tag };
30
30
utarray_push_back (loop -> waiting , & waiting );
31
31
return index ;
32
32
}
Original file line number Diff line number Diff line change 1
1
#ifndef EVENT_LOOP_H
2
2
#define EVENT_LOOP_H
3
3
4
+ /* This header defines the data structure and methods for an event loop.
5
+ * The event loop allows user code to listen to reads and writes that happen
6
+ * on file descriptors. We are using this for async io with the database
7
+ * that holds the state and to communicate between object stores, worker
8
+ * processes and the local scheduler. */
9
+
4
10
#include <poll.h>
5
11
#include <stdint.h>
6
12
@@ -13,6 +19,9 @@ typedef struct {
13
19
void * data ;
14
20
} event_loop_item ;
15
21
22
+ /* This is the main event loop datastructure which holds the pollfd struct
23
+ * for the poll system call and also user data associated with connections
24
+ * (like the status) of the connection. */
16
25
typedef struct {
17
26
/* Array of event_loop_items that hold information for connections. */
18
27
UT_array * items ;
@@ -27,7 +36,7 @@ int64_t event_loop_attach(event_loop *loop,
27
36
int type ,
28
37
void * data ,
29
38
int fd ,
30
- int events );
39
+ int events_tag );
31
40
void event_loop_detach (event_loop * loop , int64_t index , int shall_close );
32
41
int event_loop_poll (event_loop * loop );
33
42
int64_t event_loop_size (event_loop * loop );
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ void db_connect(const char *db_address,
15
15
int client_port ,
16
16
db_conn * db );
17
17
18
- /* Attach global system store onnection to event loop. Returns the index of the
18
+ /* Add the global system store onnection to event loop. Returns the index of the
19
19
* connection in the loop. */
20
20
int64_t db_attach (db_conn * db , event_loop * loop , int connection_type );
21
21
You can’t perform that action at this time.
0 commit comments