c - Reading FIFOs, resource temporary unavailable -


I have a problem with a multilevel program basically using fees to pass messages between threads

This thread is read by pipes:

  thread_args args = (thread_args) * logic; Char * FIFO_Buffer = Callback (FIFO_SIZE, size (four)); Int flag; Int fifo_win_to_send = Open (args.fifo_names [FIFO_WTS], O_RDON); If (fifo_win_to_send & lt; 0) {perror ("FIFO: Opening FIFO"); Exit (1); } Flag = fcntl (fifo_win_to_send, F_GETFL); Fcntl (fifo_win_to_seend, F_SETFL, flag | O_NONBLOCK | O_NDELAY); If read (FIFO_WINSSEND, FIFA_Buffer, FIFA_SECG) & lt; = 0) {properties ("FIFO: Window reading error in sender FIFO"); Exit (1); } If (VERBOSE_SENDER) {printf ("Read% s with Sedder from FIFO window_", FIFO_buffer); Fflush (stdout); }  

and "writing threads":

  char * fifo_buffer = calloc (FIFO_SIZE, size (four)); Thread_ararge = args = (thread_ararge) * logic; Int fifo_win_to_send = open (args.fifo_names [FIFO_WTS], o_veroni); If (fifo_win_to_send & lt; 0) {perror ("FIFO: Opening FIFO"); Exit (1); } * FIFA_Buffer = 'A'; Memcpy (FIFA_Bufer + 1, and Sequence_Number, Size); Write (fifo_win_to_seend, fifo_buffer, FIFO_SIZE); If (VERBOSE_FIFO) {printf ("to send from window:% s \ n", FIFO_buffer); Fflush (stdout); }  

FIFO files are created in the main () form before the thread is generated:

  mkdir ("temp", 0777); Four * FIFO_ID [6]; For (i = 0; i <6; i ++) {fifo_id [i] = coloc (100, size (four)); } Fifo_id [FIFO_WTS] = strcpy (FIFO_WTS], "temp / window_to_sender"); If (exit (= error! = EEXIST) {perror ("FIFO: named pipes can not be made"); exit (1);}}  <(MKIFIFA), (FINFO_ID FIFO_WTS, 0777) / Pre> 

There was an error in running the program while trying to read from FIFO.Consol reads "FIFO: Error reading window in sender FIFA: resource is temporarily unavailable" read "should not be blocked" but I Do not know whether this is correct or what is the problem. (For the first time both threads And trying to use FIFO, so I made a disturbance ...)

I think I got a problem since there is no data, so error is not blocked EAGAIN, then write something like this

  if (reado_win_to_send, fifo_buffer, FIFO_SIZE) & lt; = 0 & amp; ; Ampno; = errone! = EAGAIN) {false ("FIFO: window reading error in sender FIFO"); Exit (1); }  

Fixes the problem!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -