Skip to content

Commit

Permalink
RDMA: Fix listener priv opaque pointer (valkey-io#1194)
Browse files Browse the repository at this point in the history
struct connListener.priv should be used by connection type specific
data, static local listener data should not use this.

A RDMA config structure is going to be introduced in the next step:

```
typedef struct serverRdmaContextConfig {
    char *bindaddr;
    int bindaddr_count;
    int port;
    int rx_size;
    int comp_vector;
    ...
} serverRdmaContextConfig;
```

Then a builtin RDMA will be supported.

Signed-off-by: zhenwei pi <[email protected]>
  • Loading branch information
pizhenwei authored and proost committed Nov 9, 2024
1 parent e1ccaff commit 8d46b93
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ typedef struct rdma_listener {
* handler into pending list */
static list *pending_list;

static rdma_listener *rdma_listeners;

static ConnectionType CT_RDMA;

static int valkey_rdma_rx_size = VALKEY_RDMA_DEFAULT_RX_SIZE;
Expand Down Expand Up @@ -748,7 +750,7 @@ static rdma_listener *rdmaFdToListener(connListener *listener, int fd) {
for (int i = 0; i < listener->count; i++) {
if (listener->fd[i] != fd) continue;

return (rdma_listener *)listener->priv + i;
return &rdma_listeners[i];
}

return NULL;
Expand Down Expand Up @@ -1537,7 +1539,7 @@ int connRdmaListen(connListener *listener) {
bindaddr = default_bindaddr;
}

listener->priv = rdma_listener = zcalloc_num(bindaddr_count, sizeof(*rdma_listener));
rdma_listeners = rdma_listener = zcalloc_num(bindaddr_count, sizeof(*rdma_listener));
for (j = 0; j < bindaddr_count; j++) {
char *addr = bindaddr[j];
int optional = *addr == '-';
Expand Down Expand Up @@ -1757,13 +1759,14 @@ static int rdmaChangeListener(void) {

aeDeleteFileEvent(server.el, listener->fd[i], AE_READABLE);
listener->fd[i] = -1;
struct rdma_listener *rdma_listener = (struct rdma_listener *)listener->priv + i;
struct rdma_listener *rdma_listener = &rdma_listeners[i];
rdma_destroy_id(rdma_listener->cm_id);
rdma_destroy_event_channel(rdma_listener->cm_channel);
}

listener->count = 0;
zfree(listener->priv);
zfree(rdma_listeners);
rdma_listeners = NULL;

closeListener(listener);

Expand Down

0 comments on commit 8d46b93

Please sign in to comment.