From: Eugene Crosser Date: Tue, 12 Mar 2019 08:47:57 +0000 (+0100) Subject: save errnos X-Git-Url: http://www.average.org/gitweb/?p=psmb.git;a=commitdiff_plain;h=b59ce6ecc3287f39125703670720c8323235c8ac save errnos --- diff --git a/include/psmb.h b/include/psmb.h index 4b92756..5092f6a 100644 --- a/include/psmb.h +++ b/include/psmb.h @@ -12,6 +12,7 @@ psmb_ctx_t *psmb_new_mm(void *(*malloc)(size_t size), void *(*realloc)(void *ptr, size_t size)); psmb_result_t psmb_set_pmtu(psmb_ctx_t *ctx, unsigned int pmtu); psmb_result_t psmb_set_port(psmb_ctx_t *ctx, unsigned short pmtu); +psmb_result_t psmb_set_mgrp(psmb_ctx_t *ctx, struct {unsigned char _uc[16];} pfx, unsigned char bits); psmb_result_t psmb_open(psmb_ctx_t *ctx); void psmb_destroy(psmb_ctx_t *ctx); int psmb_getfd(psmb_ctx_t *ctx); diff --git a/src/psmb_socket.c b/src/psmb_socket.c index a7c42ef..660a563 100644 --- a/src/psmb_socket.c +++ b/src/psmb_socket.c @@ -68,20 +68,26 @@ psmb_result_t psmb_open(psmb_ctx_t *ctx) } if (setsockopt(ctx->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { + int sverr = errno; close(ctx->fd); ctx->fd = -1; + errno = sverr; return (psmb_result_t){PSMB_ERROR}; } if (setsockopt(ctx->fd, IPPROTO_IPV6, IPV6_PKTINFO, &on, sizeof(on)) < 0) { + int sverr = errno; close(ctx->fd); ctx->fd = -1; + errno = sverr; return (psmb_result_t){PSMB_ERROR}; } if (bind(ctx->fd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1) { + int sverr = errno; close(ctx->fd); ctx->fd = -1; + errno = sverr; return (psmb_result_t){PSMB_ERROR}; } return (psmb_result_t){PSMB_OK};