}
fd = makesock(IPPROTO_DCCP, 0, conf->host_arg, conf->port_arg, fo);
+ flowopt_cleanup(fo);
free(ccids);
if (fd < 0)
return fd;
}
}
-static void flowopt_cleanup(struct flowopts *fo)
+/**
+ * Deallocate all resources of a flowopts structure.
+ *
+ * \param fo A pointer as returned from flowopt_new().
+ *
+ * It's OK to pass \p NULL here in which case the function does nothing.
+ */
+void flowopt_cleanup(struct flowopts *fo)
{
struct pre_conn_opt *cur, *next;
*
* bind(2) is called on passive sockets, and connect(2) on active sockets. The
* algorithm tries all possible address combinations until it succeeds. If \a
- * fo is supplied, options are set and cleanup is performed.
+ * fo is supplied, options are set but cleanup must be performed in the caller.
*
* \return File descriptor on success, \p E_MAKESOCK on errors.
*
ret = makesock_addrinfo(l4type, passive, ai, fo);
if (ai)
freeaddrinfo(ai);
- flowopt_cleanup(fo);
if (ret < 0) {
PARA_ERROR_LOG("can not create %s socket %s#%d.\n",
layer4_name(l4type), host? host : (passive?
extern struct flowopts *flowopt_new(void);
extern void flowopt_add(struct flowopts *fo, int level, int opt,
const char *name, const void *val, int len);
+void flowopt_cleanup(struct flowopts *fo);
/** Flowopt shortcut macros */
#define OPT_ADD(fo, lev, opt, val, len) flowopt_add(fo, lev, opt, #opt, val, len)