aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2017-01-25 12:56:02 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2017-01-25 12:57:26 +0100
commit72ccba0e9bd2e371b6356a045431674d471ed5a2 (patch)
tree13184b8d0541e38e2e6dbd8f4f15a44687f88500
parent8e89e1e388ca85c4405a061cdda37be1a1278bd2 (diff)
downloadaports-72ccba0e9bd2e371b6356a045431674d471ed5a2.tar.gz
aports-72ccba0e9bd2e371b6356a045431674d471ed5a2.tar.bz2
aports-72ccba0e9bd2e371b6356a045431674d471ed5a2.tar.xz
main/lua-socket: fix udp socket on first sendto
ref #6603 sent upstream: https://github.com/diegonehab/luasocket/pull/206
-rw-r--r--main/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch49
-rw-r--r--main/lua-socket/APKBUILD12
2 files changed, 57 insertions, 4 deletions
diff --git a/main/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch b/main/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
new file mode 100644
index 0000000000..61bae6fbf4
--- /dev/null
+++ b/main/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
+
diff --git a/main/lua-socket/APKBUILD b/main/lua-socket/APKBUILD
index 6a253bbbec..8082949f5e 100644
--- a/main/lua-socket/APKBUILD
+++ b/main/lua-socket/APKBUILD
@@ -4,7 +4,7 @@ _luaversions="5.1 5.2 5.3"
pkgname=lua-socket
_name=luasocket
pkgver=3.0_rc1_git20160306
-pkgrel=1
+pkgrel=2
_ver=${pkgver%_git*}
_ver=${_ver/_rc/-rc}
pkgdesc="Networking library for Lua"
@@ -22,6 +22,7 @@ done
source="luasocket-$_ver.tar.gz::https://github.com/diegonehab/luasocket/archive/v$_ver.tar.gz
git.patch
lua-cflags.patch
+ 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch
"
# default_prepare assumes $_builddir
@@ -67,10 +68,13 @@ done
md5sums="08bd2f265b244eb4bf5c2c36bf89b759 luasocket-3.0-rc1.tar.gz
44c07dc3dd311541a50b21aaa40e36d7 git.patch
-d4319e4a20d476ea8d77a3421fca1808 lua-cflags.patch"
+d4319e4a20d476ea8d77a3421fca1808 lua-cflags.patch
+f91f7da1120e0c9f24d7df1fa31f2576 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch"
sha256sums="8b67d9b5b545e1b694753dab7bd6cdbc24c290f2b21ba1e14c77b32817ea1249 luasocket-3.0-rc1.tar.gz
414cfe53e4455fc2b416779d5eaa3ade6d97c01fa62dbffb6c9d4d4ad84bdd76 git.patch
-77d77fe688b27ae51bcf9d3ae51d43141ab85d95fd322b3904b55dbc76900418 lua-cflags.patch"
+77d77fe688b27ae51bcf9d3ae51d43141ab85d95fd322b3904b55dbc76900418 lua-cflags.patch
+f8ef57a31c95076438f22eccfbbae16e8767033269fd748dce0d0f919c8d660b 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch"
sha512sums="f6efce259aaacaa11472911471f8a13b118fe009b8953a82c6aa18b9ec829cd1293180904e56935cb130d36d267e3f27c91db2d78e03f7488f3e100571ed0540 luasocket-3.0-rc1.tar.gz
45c80e488fedc879f0217bc8a654d80da003039f5d1ff21b0dea0eb769151787dbe793e44a3dfd72cb07ff2697eceaf4fc7b55b4634cd170fa71281f19f025a5 git.patch
-fb482ad22b5caa2054b25c86edc01d1a666035930f6b55e7d12704dd78b9c31343c39eab5f13958941180d819aa37470c75fe27f1b206a4b431fb589663e2685 lua-cflags.patch"
+fb482ad22b5caa2054b25c86edc01d1a666035930f6b55e7d12704dd78b9c31343c39eab5f13958941180d819aa37470c75fe27f1b206a4b431fb589663e2685 lua-cflags.patch
+c45a12e17771a1b3b71154b5415421f524cd10b7969b4649a5f37b652cdc826721e117edb8fe64758d3520e59946e2f755b814f72cbb39ff42bf59bbcf9a64e9 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch"