I think this should be:

```
}
if (status != 0 && rac->s != -1) {
  close(rac->s);
}
```

so that we catch both connection errors and allocation failures and clean up the socket in both cases