@@ -83,9 +83,6 @@ int lcurl_easy_create(lua_State *L, int error_mode){
83
83
p -> multi = NULL ;
84
84
#if LCURL_CURL_VER_GE (7 ,56 ,0 )
85
85
p -> mime = NULL ;
86
- #endif
87
- #if LCURL_CURL_VER_GE (7 ,63 ,0 )
88
- p -> url = NULL ;
89
86
#endif
90
87
p -> storage = lcurl_storage_init (L );
91
88
p -> wr .cb_ref = p -> wr .ud_ref = LUA_NOREF ;
@@ -130,46 +127,18 @@ static int lcurl_easy_to_s(lua_State *L){
130
127
return 1 ;
131
128
}
132
129
133
- static int lcurl_easy_cleanup (lua_State * L ){
134
- lcurl_easy_t * p = lcurl_geteasy (L );
130
+ static int lcurl_easy_cleanup_storage (lua_State * L , lcurl_easy_t * p ){
135
131
int i ;
136
132
137
- if (p -> multi ){
138
- LCURL_UNUSED_VAR CURLMcode code = lcurl__multi_remove_handle (L , p -> multi , p );
139
-
140
- //! @todo what I can do if I can not remove it???
141
- }
142
-
143
- if (p -> curl ){
144
- lua_State * curL ;
145
-
146
- // In my tests when I cleanup some easy handle.
147
- // timerfunction called only for single multi handle.
148
- // Also may be this function may call `close` callback
149
- // for `curl_mimepart` structure.
150
- curL = p -> L ; lcurl__easy_assign_lua (L , p , L , 1 );
151
- curl_easy_cleanup (p -> curl );
152
- #ifndef LCURL_RESET_NULL_LUA
153
- if (curL != NULL )
154
- #endif
155
- lcurl__easy_assign_lua (L , p , curL , 1 );
156
-
157
- p -> curl = NULL ;
133
+ if (p -> storage != LUA_NOREF ){
134
+ p -> storage = lcurl_storage_free (L , p -> storage );
158
135
}
159
136
160
137
p -> post = NULL ;
161
138
#if LCURL_CURL_VER_GE (7 ,56 ,0 )
162
139
p -> mime = NULL ;
163
140
#endif
164
141
165
- #if LCURL_CURL_VER_GE (7 ,63 ,0 )
166
- p -> url = NULL ;
167
- #endif
168
-
169
- if (p -> storage != LUA_NOREF ){
170
- p -> storage = lcurl_storage_free (L , p -> storage );
171
- }
172
-
173
142
luaL_unref (L , LCURL_LUA_REGISTRY , p -> wr .cb_ref );
174
143
luaL_unref (L , LCURL_LUA_REGISTRY , p -> wr .ud_ref );
175
144
luaL_unref (L , LCURL_LUA_REGISTRY , p -> rd .cb_ref );
@@ -221,8 +190,37 @@ static int lcurl_easy_cleanup(lua_State *L){
221
190
for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ){
222
191
p -> lists [i ] = LUA_NOREF ;
223
192
}
193
+ }
224
194
195
+ static int lcurl_easy_cleanup (lua_State * L ){
196
+ lcurl_easy_t * p = lcurl_geteasy (L );
225
197
lua_settop (L , 1 );
198
+
199
+ if (p -> multi ){
200
+ LCURL_UNUSED_VAR CURLMcode code = lcurl__multi_remove_handle (L , p -> multi , p );
201
+
202
+ //! @todo what I can do if I can not remove it???
203
+ }
204
+
205
+ if (p -> curl ){
206
+ lua_State * curL ;
207
+
208
+ // In my tests when I cleanup some easy handle.
209
+ // timerfunction called only for single multi handle.
210
+ // Also may be this function may call `close` callback
211
+ // for `curl_mimepart` structure.
212
+ curL = p -> L ; lcurl__easy_assign_lua (L , p , L , 1 );
213
+ curl_easy_cleanup (p -> curl );
214
+ #ifndef LCURL_RESET_NULL_LUA
215
+ if (curL != NULL )
216
+ #endif
217
+ lcurl__easy_assign_lua (L , p , curL , 1 );
218
+
219
+ p -> curl = NULL ;
220
+ }
221
+
222
+ lcurl_easy_cleanup_storage (L , p );
223
+
226
224
lua_pushnil (L );
227
225
lua_rawset (L , LCURL_USERVALUES );
228
226
@@ -305,15 +303,8 @@ static int lcurl_easy_reset(lua_State *L){
305
303
curl_easy_reset (p -> curl );
306
304
lua_settop (L , 1 );
307
305
308
- if (p -> storage != LUA_NOREF ){
309
- int i ;
310
- for (i = 0 ; i < LCURL_LIST_COUNT ; ++ i ) {
311
- p -> lists [i ] = LUA_NOREF ;
312
- }
313
- lcurl_storage_free (L , p -> storage );
314
- p -> storage = lcurl_storage_init (L );
315
- lua_settop (L , 1 );
316
- }
306
+ lcurl_easy_cleanup_storage (L , p );
307
+ p -> storage = lcurl_storage_init (L );
317
308
318
309
return 1 ;
319
310
}
@@ -621,8 +612,6 @@ static int lcurl_easy_set_CURLU(lua_State *L) {
621
612
622
613
lcurl_storage_preserve_iv (L , p -> storage , CURLOPT_CURLU , 2 );
623
614
624
- p -> url = url ;
625
-
626
615
lua_settop (L , 1 );
627
616
return 1 ;
628
617
}
@@ -1030,8 +1019,6 @@ static int lcurl_easy_unset_CURLU(lua_State *L) {
1030
1019
1031
1020
lcurl_storage_remove_i (L , p -> storage , CURLOPT_CURLU );
1032
1021
1033
- p -> url = NULL ;
1034
-
1035
1022
lua_settop (L , 1 );
1036
1023
return 1 ;
1037
1024
}
0 commit comments