sched: rework file handling API

Replace SCH_*InputFileHandler() functions with more general
SCH_*FileHandler(), where events are specified as a new parameter and
which will later support other file events, e.g. file ready for ouput
and exception.

The file handlers have two new parameters: file descriptor and event.
This commit is contained in:
Miroslav Lichvar
2016-06-16 16:47:40 +02:00
parent aeb57a36b2
commit 0a10545314
7 changed files with 49 additions and 38 deletions

View File

@@ -57,14 +57,13 @@ struct sock_sample {
int magic;
};
static void read_sample(void *anything)
static void read_sample(int sockfd, int event, void *anything)
{
struct sock_sample sample;
RCL_Instance instance;
int sockfd, s;
int s;
instance = (RCL_Instance)anything;
sockfd = (long)RCL_GetDriverData(instance);
s = recv(sockfd, &sample, sizeof (sample), 0);
@@ -122,7 +121,7 @@ static int sock_initialise(RCL_Instance instance)
}
RCL_SetDriverData(instance, (void *)(long)sockfd);
SCH_AddInputFileHandler(sockfd, read_sample, instance);
SCH_AddFileHandler(sockfd, SCH_FILE_INPUT, read_sample, instance);
return 1;
}
@@ -131,7 +130,7 @@ static void sock_finalise(RCL_Instance instance)
int sockfd;
sockfd = (long)RCL_GetDriverData(instance);
SCH_RemoveInputFileHandler(sockfd);
SCH_RemoveFileHandler(sockfd);
close(sockfd);
}