@@ -44,14 +44,13 @@ static const mctp_eid_t local_eid_default = 8;
44
44
static char sockname [] = "\0mctp-mux" ;
45
45
46
46
struct binding {
47
- const char * name ;
48
- int (* init )(struct mctp * mctp , struct binding * binding ,
49
- mctp_eid_t eid , int n_params ,
50
- char * const * params );
51
- void (* destroy )(struct mctp * mctp , struct binding * binding );
52
- int (* get_fd )(struct binding * binding );
53
- int (* process )(struct binding * binding );
54
- void * data ;
47
+ const char * name ;
48
+ int (* init )(struct mctp * mctp , struct binding * binding , mctp_eid_t eid ,
49
+ int n_params , char * const * params );
50
+ void (* destroy )(struct mctp * mctp , struct binding * binding );
51
+ int (* init_pollfd )(struct binding * binding , struct pollfd * pollfd );
52
+ int (* process )(struct binding * binding );
53
+ void * data ;
55
54
};
56
55
57
56
struct client {
@@ -196,9 +195,10 @@ static int binding_serial_init(struct mctp *mctp, struct binding *binding,
196
195
return 0 ;
197
196
}
198
197
199
- static int binding_serial_get_fd (struct binding * binding )
198
+ static int binding_serial_init_pollfd (struct binding * binding ,
199
+ struct pollfd * pollfd )
200
200
{
201
- return mctp_serial_get_fd (binding -> data );
201
+ return mctp_serial_init_pollfd (binding -> data , pollfd );
202
202
}
203
203
204
204
static int binding_serial_process (struct binding * binding )
@@ -238,9 +238,10 @@ static void binding_astlpc_destroy(struct mctp *mctp, struct binding *binding)
238
238
mctp_astlpc_destroy (astlpc );
239
239
}
240
240
241
- static int binding_astlpc_get_fd (struct binding * binding )
241
+ static int binding_astlpc_init_pollfd (struct binding * binding ,
242
+ struct pollfd * pollfd )
242
243
{
243
- return mctp_astlpc_get_fd (binding -> data );
244
+ return mctp_astlpc_init_pollfd (binding -> data , pollfd );
244
245
}
245
246
246
247
static int binding_astlpc_process (struct binding * binding )
@@ -257,14 +258,14 @@ struct binding bindings[] = {
257
258
.name = "serial" ,
258
259
.init = binding_serial_init ,
259
260
.destroy = NULL ,
260
- .get_fd = binding_serial_get_fd ,
261
+ .init_pollfd = binding_serial_init_pollfd ,
261
262
.process = binding_serial_process ,
262
263
},
263
264
{
264
265
.name = "astlpc" ,
265
266
.init = binding_astlpc_init ,
266
267
.destroy = binding_astlpc_destroy ,
267
- .get_fd = binding_astlpc_get_fd ,
268
+ .init_pollfd = binding_astlpc_init_pollfd ,
268
269
.process = binding_astlpc_process ,
269
270
}
270
271
};
@@ -461,11 +462,7 @@ static int run_daemon(struct ctx *ctx)
461
462
462
463
ctx -> pollfds = malloc (FD_NR * sizeof (struct pollfd ));
463
464
464
- if (ctx -> binding -> get_fd ) {
465
- ctx -> pollfds [FD_BINDING ].fd =
466
- ctx -> binding -> get_fd (ctx -> binding );
467
- ctx -> pollfds [FD_BINDING ].events = POLLIN ;
468
- } else {
465
+ if (!ctx -> binding -> init_pollfd ) {
469
466
ctx -> pollfds [FD_BINDING ].fd = -1 ;
470
467
ctx -> pollfds [FD_BINDING ].events = 0 ;
471
468
}
@@ -504,6 +501,9 @@ static int run_daemon(struct ctx *ctx)
504
501
clients_changed = false;
505
502
}
506
503
504
+ if (ctx -> binding -> init_pollfd )
505
+ ctx -> binding -> init_pollfd (ctx -> binding ,
506
+ & ctx -> pollfds [FD_BINDING ]);
507
507
rc = poll (ctx -> pollfds , ctx -> n_clients + FD_NR , -1 );
508
508
if (rc < 0 ) {
509
509
warn ("poll failed" );
0 commit comments