Gentoo Archives: gentoo-commits

From: "Vadim A. Misbakh-Soloviov" <mva@×××.name>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/lua:master commit in: dev-libs/msgpack/, dev-lua/luaevent/files/
Date: Thu, 03 Jan 2019 16:53:17
Message-Id: 1546534385.45a552ddc47856c13da577e263c94898ecb79c73.mva@gentoo
1 commit: 45a552ddc47856c13da577e263c94898ecb79c73
2 Author: Vadim A. Misbakh-Soloviov <git <AT> mva <DOT> name>
3 AuthorDate: Thu Jan 3 16:50:17 2019 +0000
4 Commit: Vadim A. Misbakh-Soloviov <mva <AT> mva <DOT> name>
5 CommitDate: Thu Jan 3 16:53:05 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/lua.git/commit/?id=45a552dd
7
8 msgpack: bye
9
10 Signed-off-by: Vadim A. Misbakh-Soloviov <git <AT> mva.name>
11
12 dev-libs/msgpack/msgpack-9999.ebuild | 18 ----
13 dev-lua/luaevent/files/gc-anchoring.patch | 172 ------------------------------
14 2 files changed, 190 deletions(-)
15
16 diff --git a/dev-libs/msgpack/msgpack-9999.ebuild b/dev-libs/msgpack/msgpack-9999.ebuild
17 deleted file mode 100644
18 index 5ea6e85..0000000
19 --- a/dev-libs/msgpack/msgpack-9999.ebuild
20 +++ /dev/null
21 @@ -1,18 +0,0 @@
22 -# Copyright 1999-2016 Gentoo Foundation
23 -# Distributed under the terms of the GNU General Public License v2
24 -
25 -EAPI=6
26 -inherit cmake-multilib git-r3
27 -
28 -DESCRIPTION="MessagePack is a binary-based efficient data interchange format"
29 -HOMEPAGE="http://msgpack.org/ https://github.com/msgpack/msgpack-c/"
30 -EGIT_REPO_URI="https://github.com/${PN}/${PN}-c"
31 -
32 -LICENSE="Apache-2.0"
33 -SLOT="0"
34 -KEYWORDS=""
35 -IUSE="static-libs test"
36 -
37 -DEPEND="test? ( >=dev-cpp/gtest-1.6.0-r2[${MULTILIB_USEDEP}] )"
38 -
39 -DOCS=( CHANGELOG.md QUICKSTART-C.md QUICKSTART-CPP.md README.md )
40
41 diff --git a/dev-lua/luaevent/files/gc-anchoring.patch b/dev-lua/luaevent/files/gc-anchoring.patch
42 deleted file mode 100644
43 index 991aab1..0000000
44 --- a/dev-lua/luaevent/files/gc-anchoring.patch
45 +++ /dev/null
46 @@ -1,172 +0,0 @@
47 -From f31efa83bd76ac375c00b31c30eb731cf4fd2226 Mon Sep 17 00:00:00 2001
48 -From: Matthew Wild <mwild1@×××××.com>
49 -Date: Sat, 15 Jun 2013 22:51:03 +0100
50 -Subject: [PATCH] Ensure that callback object is always anchored to prevent the
51 - possibility of it being garbage-collected before/while the C callback runs
52 -
53 ----
54 - include/event_callback.h | 2 +
55 - src/event_callback.c | 110 ++++++++++++++++++++++++-----------------------
56 - 2 files changed, 59 insertions(+), 53 deletions(-)
57 -
58 -diff --git a/include/event_callback.h b/include/event_callback.h
59 -index 9d68b26..6d7a2f1 100644
60 ---- a/include/event_callback.h
61 -+++ b/include/event_callback.h
62 -@@ -28,7 +28,9 @@
63 - typedef struct {
64 - struct event ev;
65 - le_base* base;
66 -+ int selfRef;
67 - int callbackRef;
68 -+ int running;
69 - struct timeval timeout;
70 - } le_callback;
71 -
72 -diff --git a/src/event_callback.c b/src/event_callback.c
73 -index afe8773..9e705be 100644
74 ---- a/src/event_callback.c
75 -+++ b/src/event_callback.c
76 -@@ -27,11 +27,10 @@
77 -
78 - #define EVENT_CALLBACK_ARG_MT "EVENT_CALLBACK_ARG_MT"
79 -
80 --void freeCallbackArgs(le_callback* arg, lua_State* L) {
81 -- if(arg->base) {
82 -- arg->base = NULL;
83 -- event_del(&arg->ev);
84 -- luaL_unref(L, LUA_REGISTRYINDEX, arg->callbackRef);
85 -+void freeCallback(le_callback* cb, lua_State* L) {
86 -+ if(cb->callbackRef != LUA_NOREF) {
87 -+ luaL_unref(L, LUA_REGISTRYINDEX, cb->callbackRef);
88 -+ cb->callbackRef = LUA_NOREF;
89 - }
90 - }
91 - /* le_callback is allocated at the beginning of the coroutine in which it
92 -@@ -40,60 +39,62 @@ is used, no need to manually de-allocate */
93 - /* Index for coroutine is fd as integer for *nix, as lightuserdata for Win */
94 - void luaevent_callback(int fd, short event, void* p) {
95 - le_callback* cb = p;
96 -+ struct event *ev = &cb->ev;
97 - lua_State* L;
98 -- int ret;
99 -+ int ret = -1;
100 - struct timeval new_tv = { 0, 0 };
101 -- le_base* base;
102 -- assert(cb);
103 -- if(!cb->base)
104 -- return; /* Event has already been collected + destroyed */
105 -- assert(cb->base->loop_L);
106 -- L = cb->base->loop_L;
107 -- lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef);
108 -- lua_pushinteger(L, event);
109 -- /* cb->base may be NULL after the pcall, if the event is destroyed */
110 -- base = cb->base;
111 -- if(lua_pcall(L, 1, 2, 0))
112 -- {
113 -- base->errorMessage = luaL_ref(L, LUA_REGISTRYINDEX);
114 -- event_base_loopbreak(base->base);
115 -- lua_pop(L, 1);
116 -- return;
117 -- }
118 -- if(!cb->base) {
119 -- lua_pop(L, 2);
120 -- return; /* event was destroyed during callback */
121 -- }
122 -- /* If nothing is returned, re-use the old event value */
123 -- ret = luaL_optinteger(L, -2, event);
124 -- /* Clone the old timeout value in case a new one wasn't set */
125 -- memcpy(&new_tv, &cb->timeout, sizeof(new_tv));
126 -- if(lua_isnumber(L, -1)) {
127 -- double newTimeout = lua_tonumber(L, -1);
128 -- if(newTimeout > 0) {
129 -- load_timeval(newTimeout, &new_tv);
130 -+ if(cb->callbackRef != LUA_NOREF) {
131 -+ L = cb->base->loop_L;
132 -+ lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef);
133 -+ lua_pushinteger(L, event);
134 -+ cb->running = 1;
135 -+ if(lua_pcall(L, 1, 2, 0))
136 -+ {
137 -+ cb->running = 0;
138 -+ cb->base->errorMessage = luaL_ref(L, LUA_REGISTRYINDEX);
139 -+ event_base_loopbreak(cb->base->base);
140 -+ lua_pop(L, 1); /* Pop the 'false' from pcall */
141 -+ return;
142 - }
143 -+ cb->running = 0;
144 -+ /* If nothing is returned, re-use the old event value */
145 -+ ret = luaL_optinteger(L, -2, event);
146 - }
147 -- lua_pop(L, 2);
148 -- if(ret == -1) {
149 -- freeCallbackArgs(cb, L);
150 -- } else {
151 -- struct event *ev = &cb->ev;
152 -- int newEvent = ret;
153 -- if( newEvent != event || (cb->timeout.tv_sec != new_tv.tv_sec || cb->timeout.tv_usec != new_tv.tv_usec) ) {
154 -- struct timeval *ptv = &cb->timeout;
155 -- cb->timeout = new_tv;
156 -- event_del(ev);
157 -- event_set(ev, fd, EV_PERSIST | newEvent, luaevent_callback, cb);
158 -- /* Assume cannot set a new timeout.. */
159 -- event_add(ev, ptv);
160 -+ if(ret == -1 || cb->callbackRef == LUA_NOREF) {
161 -+ event_del(ev);
162 -+ freeCallback(cb, L);
163 -+ assert(cb->selfRef != LUA_NOREF);
164 -+ luaL_unref(L, LUA_REGISTRYINDEX, cb->selfRef);
165 -+ cb->selfRef = LUA_NOREF;
166 -+ } else if( ret != event || (cb->timeout.tv_sec != new_tv.tv_sec || cb->timeout.tv_usec != new_tv.tv_usec) ) {
167 -+ /* Clone the old timeout value in case a new one wasn't set */
168 -+ memcpy(&new_tv, &cb->timeout, sizeof(new_tv));
169 -+ if(lua_isnumber(L, -1)) {
170 -+ double newTimeout = lua_tonumber(L, -1);
171 -+ if(newTimeout > 0) {
172 -+ load_timeval(newTimeout, &new_tv);
173 -+ }
174 - }
175 -+ struct timeval *ptv = &cb->timeout;
176 -+ cb->timeout = new_tv;
177 -+ event_del(ev);
178 -+ event_set(ev, fd, EV_PERSIST | ret, luaevent_callback, cb);
179 -+ /* Assume cannot set a new timeout.. */
180 -+ event_add(ev, ptv);
181 - }
182 -+ lua_pop(L, 2); /* Pop two results from call */
183 - }
184 -
185 - static int luaevent_cb_gc(lua_State* L) {
186 -- le_callback* arg = luaL_checkudata(L, 1, EVENT_CALLBACK_ARG_MT);
187 -- freeCallbackArgs(arg, L);
188 -+ freeCallback(luaL_checkudata(L, 1, EVENT_CALLBACK_ARG_MT), L);
189 -+ return 0;
190 -+}
191 -+
192 -+static int luaevent_cb_close(lua_State* L) {
193 -+ le_callback *cb = luaL_checkudata(L, 1, EVENT_CALLBACK_ARG_MT);
194 -+ if(!cb->running)
195 -+ event_del(&cb->ev);
196 -+ freeCallback(cb, L); // Release reference to Lua callback
197 - return 0;
198 - }
199 -
200 -@@ -104,6 +105,9 @@ le_callback* event_callback_push(lua_State* L, int baseIdx, int callbackIdx) {
201 - le_base *base = event_base_get(L, baseIdx);
202 - luaL_checktype(L, callbackIdx, LUA_TFUNCTION);
203 - cb = lua_newuserdata(L, sizeof(*cb));
204 -+ lua_pushvalue(L, -1);
205 -+ cb->selfRef = luaL_ref(L, LUA_REGISTRYINDEX);
206 -+ cb->running = 0;
207 - luaL_getmetatable(L, EVENT_CALLBACK_ARG_MT);
208 - lua_setmetatable(L, -2);
209 -
210 -@@ -119,7 +123,7 @@ void event_callback_register(lua_State* L) {
211 - lua_pushcfunction(L, luaevent_cb_gc);
212 - lua_setfield(L, -2, "__gc");
213 - lua_newtable(L);
214 -- lua_pushcfunction(L, luaevent_cb_gc);
215 -+ lua_pushcfunction(L, luaevent_cb_close);
216 - lua_setfield(L, -2, "close");
217 - lua_setfield(L, -2, "__index");
218 - lua_pop(L, 1);