@@ -70,7 +70,6 @@ svc_recv(void *arg, unsigned short e)
7070 if (e & ELE_HANGUP ) {
7171 hangup :
7272 eloop_exit (sctx -> svc_ctx -> ctx_eloop , EXIT_SUCCESS );
73- eloop_exit (sctx -> svc_eloop , EXIT_SUCCESS );
7473 return ;
7574 }
7675 if (e != ELE_READ ) {
@@ -109,12 +108,12 @@ svc_recv(void *arg, unsigned short e)
109108 nread = recvmsg (sctx -> svc_fd , & msg , 0 );
110109 if (nread == -1 ) {
111110 logerr ("%s: recvmsg cmd" , __func__ );
112- goto out ;
111+ return ;
113112 }
114113 if ((size_t )nread != sizeof (cmd ) + cmd .sc_datalen ) {
115114 logerrx ("%s: read datalen mismatch: %zd != %zd" , __func__ ,
116115 nread , sizeof (cmd ) + cmd .sc_datalen );
117- goto out ;
116+ return ;
118117 }
119118
120119 sr -> sr_datalen = cmd .sc_datalen ;
@@ -125,9 +124,6 @@ svc_recv(void *arg, unsigned short e)
125124 if (sctx -> svc_dispatch != NULL )
126125 sctx -> svc_dispatch (sctx , (struct plugin * )cmd .sc_plugin ,
127126 cmd .sc_cmd , sctx -> svc_buf , cmd .sc_datalen );
128- out :
129- if (sctx -> svc_eloop != NULL )
130- eloop_exit (sctx -> svc_eloop , EXIT_SUCCESS );
131127}
132128
133129ssize_t
@@ -184,16 +180,17 @@ svc_runv(struct svc_ctx *sctx, struct plugin *p, unsigned int cmd,
184180 struct iovec * iov , int iovlen , ssize_t * res , void * * rdata , size_t * rlen )
185181{
186182 struct svc_result * result = & sctx -> svc_result ;
187- int err ;
183+ int events ;
188184
189185 if (svc_sendv (sctx , p , cmd , 0 , iov , iovlen ) == -1 ) {
190186 logerr ("%s: svc_write" , __func__ );
191187 return -1 ;
192188 }
193189
194- err = eloop_start (sctx -> svc_eloop );
195- if (err == -1 )
190+ events = eloop_waitfd (sctx -> svc_fd );
191+ if (events == -1 )
196192 return -1 ;
193+ svc_recv (sctx , (unsigned short )events );
197194
198195 if (result -> sr_result == -1 )
199196 errno = result -> sr_errno ;
@@ -203,7 +200,7 @@ svc_runv(struct svc_ctx *sctx, struct plugin *p, unsigned int cmd,
203200 * rdata = result -> sr_data ;
204201 if (rlen != NULL )
205202 * rlen = result -> sr_datalen ;
206- return err ;
203+ return 0 ;
207204}
208205
209206int
@@ -236,7 +233,6 @@ svc_init(struct ctx *ctx, const char *name,
236233 sctx -> svc_ctx = ctx ;
237234 sctx -> svc_fd = -1 ;
238235 sctx -> svc_dispatch = NULL ;
239- sctx -> svc_eloop = NULL ;
240236
241237 sctx -> svc_buflen = 1024 ;
242238 sctx -> svc_buf = malloc (sctx -> svc_buflen );
@@ -265,16 +261,6 @@ svc_init(struct ctx *ctx, const char *name,
265261 default :
266262 sctx -> svc_fd = fdset [0 ];
267263 close (fdset [1 ]);
268- sctx -> svc_eloop = eloop_new ();
269- if (sctx -> svc_eloop == NULL ) {
270- logerr ("%s: eloop_new" , __func__ );
271- goto error ;
272- }
273- if (eloop_event_add (sctx -> svc_eloop , sctx -> svc_fd , ELE_READ ,
274- svc_recv , sctx ) == -1 ) {
275- logerr ("%s: eloop_event_add" , __func__ );
276- goto error ;
277- }
278264 logdebugx ("service: spawned %s on pid %ld" , name , (long )pid );
279265 return sctx ;
280266 }
@@ -333,6 +319,5 @@ svc_free(struct svc_ctx *ctx)
333319 if (ctx -> svc_fd != -1 )
334320 close (ctx -> svc_fd );
335321 free (ctx -> svc_buf );
336- eloop_free (ctx -> svc_eloop );
337322 free (ctx );
338323}
0 commit comments