polypath is are going to want this. No functional change.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
int failmsgclass);
/* Fills in us->fd. Logs any errors with lg_[v]perror. */
+void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us);
+ /* Idempotent. No errors are possible. */
+
void udp_socks_register(struct udpcommon *uc, struct udpsocks *socks);
void udp_socks_deregister(struct udpcommon *uc, struct udpsocks *socks);
return True;
}
+void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us)
+{
+ if (us->fd>=0) {
+ close(us->fd);
+ us->fd=-1;
+ }
+}
+
bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us,
int failmsgclass)
{
const union iaddr *addr=&us->addr;
struct commcommon *cc=&uc->cc;
+ us->fd=-1;
#define FAIL_LG 0, cc->cl.description, &cc->loc, failmsgclass
#define FAIL(...) do{ \
return True;
failed:
- if (us->fd>=0) {
- close(us->fd);
- us->fd=-1;
- }
+ udp_destroy_socket(uc,us);
return False;
#undef FAIL