Skip to content

Commit 1859505

Browse files
committed
address ion's comments
1 parent 0b7d81c commit 1859505

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

common.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
} \
2626
} while (0);
2727

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+
2840
#define UNIQUE_ID_SIZE 20
2941

3042
typedef struct { unsigned char id[UNIQUE_ID_SIZE]; } unique_id;

event_loop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ int64_t event_loop_attach(event_loop *loop,
2121
int type,
2222
void *data,
2323
int fd,
24-
int events) {
24+
int events_tag) {
2525
assert(utarray_len(loop->items) == utarray_len(loop->waiting));
2626
int64_t index = utarray_len(loop->items);
2727
event_loop_item item = {.type = type, .data = data};
2828
utarray_push_back(loop->items, &item);
29-
struct pollfd waiting = {.fd = fd, .events = events};
29+
struct pollfd waiting = {.fd = fd, .events = events_tag};
3030
utarray_push_back(loop->waiting, &waiting);
3131
return index;
3232
}

event_loop.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#ifndef EVENT_LOOP_H
22
#define EVENT_LOOP_H
33

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+
410
#include <poll.h>
511
#include <stdint.h>
612

@@ -13,6 +19,9 @@ typedef struct {
1319
void *data;
1420
} event_loop_item;
1521

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. */
1625
typedef struct {
1726
/* Array of event_loop_items that hold information for connections. */
1827
UT_array *items;
@@ -27,7 +36,7 @@ int64_t event_loop_attach(event_loop *loop,
2736
int type,
2837
void *data,
2938
int fd,
30-
int events);
39+
int events_tag);
3140
void event_loop_detach(event_loop *loop, int64_t index, int shall_close);
3241
int event_loop_poll(event_loop *loop);
3342
int64_t event_loop_size(event_loop *loop);

state/db.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void db_connect(const char *db_address,
1515
int client_port,
1616
db_conn *db);
1717

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
1919
* connection in the loop. */
2020
int64_t db_attach(db_conn *db, event_loop *loop, int connection_type);
2121

0 commit comments

Comments
 (0)