summaryrefslogtreecommitdiff
path: root/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
diff options
context:
space:
mode:
authorKiyoshi Aman <kiyoshi.aman+apkfission@gmail.com>2018-10-09 08:21:38 -0500
committerKiyoshi Aman <kiyoshi.aman+apkfission@gmail.com>2018-10-09 21:32:22 -0500
commitf5df416fd9b9d428aaf8c997e50b89c2710a010f (patch)
tree4ab3f359989b14280acae13b28404af5a9cbca02 /user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
parent3a977ae559552329a08cc97802193eb019e398e9 (diff)
downloadpackages-f5df416fd9b9d428aaf8c997e50b89c2710a010f.tar.gz
packages-f5df416fd9b9d428aaf8c997e50b89c2710a010f.tar.bz2
packages-f5df416fd9b9d428aaf8c997e50b89c2710a010f.tar.xz
packages-f5df416fd9b9d428aaf8c997e50b89c2710a010f.zip
user/lua-socket: new package for lua-sec & prosody
Diffstat (limited to 'user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch')
-rw-r--r--user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch b/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
new file mode 100644
index 000000000..61bae6fbf
--- /dev/null
+++ b/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
@@ -0,0 +1,49 @@
+From 3041a808c3797e3c87272d71666e7b2f7c7a9f46 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 25 Jan 2017 12:43:29 +0100
+Subject: [PATCH] Create socket on first sendto if family agnostic udp() was
+ used
+
+Create socket and set family on first sendto() if udp() was created
+without address family.
+
+Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
+---
+ src/udp.c | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/src/udp.c b/src/udp.c
+index ec97252..605c195 100644
+--- a/src/udp.c
++++ b/src/udp.c
+@@ -189,6 +189,27 @@ static int meth_sendto(lua_State *L) {
+ lua_pushstring(L, gai_strerror(err));
+ return 2;
+ }
++
++ /* create socket if on first sendto if AF_UNSPEC was set */
++ if (udp->family == AF_UNSPEC && udp->sock == SOCKET_INVALID) {
++ struct addrinfo *ap;
++ const char *errstr = NULL;
++ for (ap = ai; ap != NULL; ap = ap->ai_next) {
++ errstr = inet_trycreate(&udp->sock, ap->ai_family, SOCK_DGRAM, 0);
++ if (errstr == NULL) {
++ socket_setnonblocking(&udp->sock);
++ udp->family = ap->ai_family;
++ break;
++ }
++ }
++ if (errstr != NULL) {
++ lua_pushnil(L);
++ lua_pushstring(L, errstr);
++ freeaddrinfo(ai);
++ return 2;
++ }
++ }
++
+ timeout_markstart(tm);
+ err = socket_sendto(&udp->sock, data, count, &sent, ai->ai_addr,
+ (socklen_t) ai->ai_addrlen, tm);
+--
+2.11.0
+