Project

General

Profile

Revision 424

changed various things in colonet dragonfly and server to make stuff work

View differences:

ConnectionPool.cpp
258 258
  return number_clients_ready;
259 259
}
260 260

  
261

  
261
/**
262
*/
262 263
int ConnectionPool::read_data(int pool_index, int client_file_descriptor) {
263 264
  char temporary_buffer[READ_BUFFER_SIZE];
264 265
  char temporary_command_buffer[READ_BUFFER_SIZE+1];
......
288 289
      memmove(temporary_buffer, temporary_buffer+length, READ_BUFFER_SIZE - length);
289 290
    }
290 291

  
291
    printf("Read buffer is %s\n", read_buffer[pool_index]);
292
    printf("read_data: Read buffer is %s\n", read_buffer[pool_index]);
292 293

  
293 294
    char* newline_position;
294 295

  
......
301 302
      //TODO: this is from before all this code was put in the loop.  reconsider
302 303
      //      how to check this error condition and do it elsewhere
303 304
      if (!newline_position && (read_buffer_size[pool_index] == READ_BUFFER_SIZE)) {
304
	read_buffer_size[pool_index] = 0;
305
	break;
305
        read_buffer_size[pool_index] = 0;
306
        break;
306 307
      }
307 308

  
308 309
      //if no newline is found then there is not a command in the buffer
309 310
      if (!newline_position) {
310
	break;
311
        break;
311 312
      }
312 313

  
313 314
      command_length = (newline_position - read_buffer[pool_index])+1;
......
315 316
      //the newline was found in garbage in the currently not used portion
316 317
      // of the read buffer
317 318
      if (command_length > read_buffer_size[pool_index]) {
318
	break;
319
        break;
319 320
      }
320 321

  
321 322
      memcpy(temporary_command_buffer, read_buffer[pool_index], command_length);
......
323 324
      temporary_command_buffer[command_length-1] = '\0';
324 325
      //did this because telnet was putting a \r\n on the end instead of just \n
325 326
      if (isspace(temporary_command_buffer[command_length-2])) {
326
	temporary_command_buffer[command_length-2] = '\0';
327
        temporary_command_buffer[command_length-2] = '\0';
327 328
      }
328 329

  
329 330
      memmove(read_buffer[pool_index], read_buffer[pool_index]+command_length, read_buffer_size[pool_index] - command_length);
330 331
      read_buffer_size[pool_index] -= command_length;
331 332

  
332 333
      if (command_length > MAX_COMMAND_LEN) {
333
	printf("The command was too long.  Tossing command out.\n");
334
	break;
334
        fprintf(stderr, "Command was too long.  Tossing command out.\n");
335
        break;
335 336
      }
336 337

  
337 338
      Command command(this);
338 339
      if (command.parse_command(temporary_command_buffer, pool_index) != 0) {
339
	printf("There was an error parsing command\n");
340
	break;
340
        fprintf(stderr, "Error parsing command\n");
341
        break;
341 342
      }
342 343
    }
343 344
  }
......
345 346
  return 0;
346 347
}
347 348

  
348

  
349 349
int ConnectionPool::write_data(int pool_index, int client_file_descriptor) {
350 350
  if (write_buffer_size[pool_index] == 0) {
351 351
    return 0;

Also available in: Unified diff