[examples] streamfl* bugfixes;
This commit is contained in:
		
							parent
							
								
									ba630086e9
								
							
						
					
					
						commit
						bc3d8eef39
					
				| @ -135,7 +135,7 @@ static int __dirlist(FILE *f, struct _remote_host *remote, struct _astream *rstr | ||||
| 
 | ||||
|   rstream->print_head(f); | ||||
| 
 | ||||
|   stream = sxstream_open(link, opt, stream_tid, SXE_O_READ | SXE_O_TRUNC); | ||||
|   stream = sxstream_open(link, opt, stream_tid, SXE_O_READ); | ||||
|   if(!stream) { | ||||
|     fprintf(stderr, "Failed to open stream with %d ID (%d).\n", stream_tid, errno); | ||||
|     return EINVAL; | ||||
| @ -144,6 +144,10 @@ static int __dirlist(FILE *f, struct _remote_host *remote, struct _astream *rstr | ||||
|   while((list = sxstream_read(stream)) != NULL) | ||||
|     rstream->print_op(f, list); | ||||
| 
 | ||||
|   if(errno != SXE_EOS) { | ||||
|     fprintf(stderr, "Reading failed (%d)\n", errno); | ||||
|   } | ||||
| 
 | ||||
|   sxstream_close(stream); | ||||
| 
 | ||||
|   return 0; | ||||
|  | ||||
| @ -183,13 +183,17 @@ static size_t dirlist_read(struct sxstream_opened *stream, size_t sz, uint64_t o | ||||
|   list_head_t *llist_prev = sxstream_opened_getelist(stream); | ||||
|   list_head_t *llist_new = NULL; | ||||
| 
 | ||||
|   if(!pslist || !llist_new) return -1; | ||||
|   if(!pslist) return -1; | ||||
| 
 | ||||
|   /* read and fill new list */ | ||||
|   if(readdir_r(pslist->dp, &(pslist->dent), &(pslist->dres))) | ||||
|     return -1; | ||||
|   if(readdir_r(pslist->dp, &(pslist->dent), &(pslist->dres))) return -1; | ||||
| 
 | ||||
|   /* if finished return 0 */ | ||||
|   if(!pslist->dres) return 0; | ||||
|   if(!pslist->dres) { | ||||
|     if(llist_prev) sxstream_generic_slist_free(llist_prev); | ||||
|     stream->ent_buf = NULL; | ||||
|     return 0; | ||||
|   } | ||||
|   /* allocate a new */ | ||||
|   if(!(llist_new = sxstream_generic_slist_alloc())) return -1; | ||||
|   else { /* fill this list */ | ||||
| @ -202,7 +206,7 @@ static size_t dirlist_read(struct sxstream_opened *stream, size_t sz, uint64_t o | ||||
|       goto __fail; | ||||
|   } | ||||
|   /* otherwise destroy last list */ | ||||
|   sxstream_generic_slist_free(llist_prev); | ||||
|   if(llist_prev) sxstream_generic_slist_free(llist_prev); | ||||
|   *rlist = llist_new; /* assign new list */ | ||||
| 
 | ||||
|   return 1; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user