Changeset 5608:584b36c566e2 in roaraudio for libroar/proto.c
- Timestamp:
- 07/31/12 15:31:35 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/proto.c
r5467 r5608 148 148 } 149 149 150 static inline int _libroar_msgresyncer(struct roar_vio_calls * vio, size_t len) { 151 char buffer[2*LIBROAR_BUFFER_MSGDATA]; // this is always called with len > LIBROAR_BUFFER_MSGDATA. 152 ssize_t ret; 153 size_t errorc = 0; 154 155 while (len && errorc < 4) { 156 ret = roar_vio_read(vio, buffer, len > sizeof(buffer) ? sizeof(buffer) : len); 157 if ( ret == (size_t)-1 ) { 158 errorc++; 159 } else { 160 errorc = 0; 161 len -= ret; 162 } 163 } 164 165 if ( len ) 166 return -1; // last error is still set. 167 return 0; 168 } 169 150 170 int roar_vrecv_message2(struct roar_vio_calls * vio, struct roar_message * mes, char ** data, 151 171 struct roar_error_frame * errorframe) { … … 269 289 } else { 270 290 if ( data == NULL ) { 271 roar_err_set(ROAR_ERROR_MSGSIZE); 291 if ( _libroar_msgresyncer(vio, mes->datalen) == -1 ) { 292 roar_err_set(ROAR_ERROR_BADCKSUM); 293 } else { 294 roar_err_set(ROAR_ERROR_MSGSIZE); 295 } 272 296 return -1; 273 297 } 274 298 275 299 if ( (*data = roar_mm_malloc(mes->datalen)) == NULL ) { 276 roar_err_set(ROAR_ERROR_NOMEM); 300 if ( _libroar_msgresyncer(vio, mes->datalen) == -1 ) { 301 roar_err_set(ROAR_ERROR_BADCKSUM); 302 } else { 303 roar_err_set(ROAR_ERROR_NOMEM); 304 } 277 305 return -1; 278 306 }
Note: See TracChangeset
for help on using the changeset viewer.