Problem with Kernel thread and soreceive
Problem with Kernel thread and soreceive
- Subject: Problem with Kernel thread and soreceive
- From: Matt Jaffa <email@hidden>
- Date: Fri, 29 Oct 2004 20:02:45 -0600
Hi,
I have a thread that I create in my nke_start function called when my
nke is loaded.
And as you can see in my thread below with the code I include I create
a socket(created in the start function of the nke, this is a global
struct socket).
and then bind it to port 9856 and this is a UDP socket, the soreceive
is in a while always receiving data. This is working fine but after
awhile and when the data is somewhat big, it causes the soreceive to do
nothing but return so it doesn't want on it anymore and causes my NKE
to eat up the cpu like crazy and stop receiving data.
Notice anything bad in the code below?
Thanks,
Matt
void mythread(void * one) {
int funnel_state;
funnel_state = thread_funnel_set(network_flock, TRUE);
struct ifnet *ifp;
struct ifnet *sendg = NULL;
TAILQ_FOREACH(ifp, &ifnet, if_link) {
printf("This is the name: %s, This is the number: %d
\n",ifp->if_name, ifp->if_unit);
if(( bcmp(ifp->if_name,"en",strlen(ifp->if_name))== 0) &&
(ifp->if_unit == 0) ) {
sendg = ifp;
printf("IS SENDG NULL?: %d\n", sendg == NULL);
//printf("Install filter on bsdname = %s\n", bsdName);
//here is where we
}
}
theconnect->so_snd.sb_timeo = 15;
theconnect->so_rcv.sb_flags |= SB_NOINTR;
theconnect->so_snd.sb_flags |= SB_NOINTR;
//int test = 0;
printf("The thread was called without crashing\n");
struct mbuf *cm2 = 0;
struct iovec aiov2[1];
struct uio auio2 = { 0 };
char test2[1600];
aiov2[0].iov_base = test2;
aiov2[0].iov_len = 1500;
auio2.uio_iov = aiov2;
auio2.uio_iovcnt = 1;
auio2.uio_rw = UIO_WRITE | UIO_READ;
auio2.uio_segflg = UIO_SYSSPACE;
auio2.uio_offset = 0;
auio2.uio_resid = 1500;
printf("Check\n");
struct sockaddr_in name;
name.sin_addr.s_addr = htonl(INADDR_ANY);
name.sin_len = sizeof(struct sockaddr_in);
name.sin_family = AF_INET; // Set the server's family
name.sin_port = htons((unsigned short) 9856); // Set the port to
connect to...
int tes = sobind(theconnect,(struct sockaddr*)&name);
if(tes == 0) {
while(1) {
//printf("rerror: %d\n", 33);
/*test++;
if(test >= 9)
return;*/
int flags = MSG_DONTWAIT;
printf("Socket state: %x\n", theconnect->so_state);
int rerror = soreceive(theconnect, (struct sockaddr **)0, &auio2,
&cm2, 0, 0);
printf("rerror: %d\n", rerror);
if (rerror) {
} else {
if(cm2 != NULL) {
printf("cm2 is not null\n");
//char * final = mtod(cm2, char*);
printf("sendg == NULL2nd: %d\n", sendg == NULL);
if(sendg != NULL) {
int retval = (*sendg->if_output)(sendg, cm2);
printf("What is retval: %d\n", retval);
}
}
}
}
}
thread_funnel_set(network_flock, funnel_state);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden