Date: Wed Apr 10 22:32:46 CEST 2002
User: Derick Rethans
Directory: srm/main/src
Log Message:
[1.50]
- Fix bug where data packet retrieval was interupted by a signal
- Fix bug in packet receiving (length parameter was a byte)
- Moved some debug stuff around
- Fixed a spelling error
Modified files:
srm/main/src/connection.c (version: 1.62)
srm/main/src/srm_value.c (version: 1.45)
[FILE: /srm/main/src/connection.c]
--- srm/main/src/connection.c:1.61 Fri Feb 22 20:23:02 2002 GMT
+++ srm/main/src/connection.c Wed Apr 10 18:32:46 2002 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.61 2002/02/22 21:23:02 derick Exp $ */
+/* $Id: cvstemp,v 1.62 2002/04/10 20:32:46 derick Exp $ */
/* The contents of this file are subject to the Vulcan Logic Public
* License Version 1.1 (the "License"); you may not use this file
@@ -259,7 +259,7 @@
server_send_packet (fd, PKT_HANDSHAKE2, NULL, 0, packet);
} /* 1}}} */
-static void srm_process_command (int fd, srm_ui8* packet, srm_ui8 size, srm_ui8* data, srm_ui8 dsize) /* {{{1 */
+static void srm_process_command (int fd, srm_ui8* packet, srm_ui8 size, srm_ui8* data, srm_ui32 dsize) /* {{{1 */
{
struct srm_value* command;
struct srm_value* cmd;
@@ -272,9 +272,11 @@
ret_val = srm_value_init();
/* Get command from packet */
- deserialize (data, dsize, (struct srm_value**) &command, 0);
#ifdef SRM_DEBUG
dump_packet ((srm_ui8*) data, dsize);
+#endif
+ deserialize (data, dsize, (struct srm_value**) &command, 0);
+#ifdef SRM_DEBUG
srm_value_dump (command, 0);
#endif
params = SRMVALP_LIST(command);
@@ -320,10 +322,10 @@
ret_val = srm_value_init();
/* Getting data from packet */
- deserialize (pdata, dsize, (struct srm_value**) &command, 0);
#ifdef SRM_DEBUG
dump_packet ((srm_ui8*) pdata, dsize);
#endif
+ deserialize (pdata, dsize, (struct srm_value**) &command, 0);
srm_fmt_message (LL_DATA, "Notice", "Store data");
e = SRM_LLIST_HEAD (command->list);
store = (struct srm_value *) SRM_LLIST_VALP(e);
@@ -383,10 +385,10 @@
ret_val = srm_value_init();
/* Getting data from packet */
- deserialize (pdata, dsize, (struct srm_value**) &command, 0);
#ifdef SRM_DEBUG
dump_packet ((srm_ui8*) pdata, dsize);
#endif
+ deserialize (pdata, dsize, (struct srm_value**) &command, 0);
srm_fmt_message (LL_DATA, "Notice", "Retrieve data");
store = (struct srm_value *) SRM_LLIST_VALP (SRM_LLIST_HEAD (command->list));
key = (struct srm_value *) SRM_LLIST_VALP (SRM_LLIST_NEXT (SRM_LLIST_HEAD (command->list)));
@@ -439,10 +441,10 @@
ret_val = srm_value_init();
/* Getting data from packet */
- deserialize (pdata, dsize, (struct srm_value**) &command, 0);
#ifdef SRM_DEBUG
dump_packet ((srm_ui8*) pdata, dsize);
#endif
+ deserialize (pdata, dsize, (struct srm_value**) &command, 0);
srm_fmt_message (LL_DATA, "Notice", "Delete data");
store = (struct srm_value *) SRM_LLIST_VALP (SRM_LLIST_HEAD (command->list));
key = (struct srm_value *) SRM_LLIST_VALP (SRM_LLIST_NEXT (SRM_LLIST_HEAD (command->list)));
@@ -515,7 +517,7 @@
{
struct pkt_header header;
srm_ui8 * data = NULL;
- srm_ui32 length = 0, dlength = 0;
+ srm_ui32 length = 0, n = 0, read_bytes = 0;
length = read (fd, &header, sizeof (header));
if (length < sizeof (header) || length == -1) {
@@ -526,10 +528,19 @@
#ifdef SRM_DEBUG
dump_packet ((srm_ui8*) &header, length);
#endif
- /* Checking for more data if needed */
+ /* Checking for more data if needed */
if (header.data_length != 0) {
data = malloc (header.data_length);
- dlength = read (fd, data, header.data_length);
+ while (read_bytes < header.data_length) {
+ n = read (fd, data + read_bytes, header.data_length - read_bytes);
+ if (n < 0) {
+ break;
+ }
+ read_bytes += n;
+ }
+ if (n < header.data_length) {
+ connection_abort_with_error (fd, "Packet is invalid");
+ }
}
if (/*srm_pkt_validate (fd, header, length)*/TRUE)
{
@@ -538,22 +549,22 @@
srm_do_handshake (fd, (srm_ui8*) &header);
break;
case PKT_COMMAND:
- srm_process_command (fd, (srm_ui8*) &header, length, (srm_ui8*) data, dlength);
+ srm_process_command (fd, (srm_ui8*) &header, length, (srm_ui8*) data, header.data_length);
break;
case PKT_DISCONNECT:
connection_close (fd);
break;
case PKT_STORE_DATA:
- srm_process_store_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, dlength);
+ srm_process_store_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, header.data_length);
break;
case PKT_RETRIEVE_DATA:
- srm_process_retrieve_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, dlength);
+ srm_process_retrieve_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, header.data_length);
break;
case PKT_DELETE_DATA:
- srm_process_delete_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, dlength);
+ srm_process_delete_data (fd, (srm_ui8*) &header, length, (srm_ui8*) data, header.data_length);
break;
default:
- connection_abort_with_error (fd, "Unkown packet type");
+ connection_abort_with_error (fd, "Unknown packet type");
}
} else {
connection_abort_with_error (fd, "Packet is invalid");
[FILE: /srm/main/src/srm_value.c]
--- srm/main/src/srm_value.c:1.44 Sat Feb 23 18:03:36 2002 GMT
+++ srm/main/src/srm_value.c Wed Apr 10 18:32:46 2002 GMT
@@ -1,4 +1,4 @@
-/* $Id: cvstemp,v 1.44 2002/02/23 19:03:36 derick Exp $ */
+/* $Id: cvstemp,v 1.45 2002/04/10 20:32:46 derick Exp $ */
/* The contents of this file are subject to the Vulcan Logic Public
* License Version 1.1 (the "License"); you may not use this file
@@ -423,7 +423,7 @@
srm_ui32 key_l;
if (offset > d_length) {
- srm_error (ERROR_SERIALIZE, "deserialize: offset larger then data block");
+ srm_error (ERROR_SERIALIZE, "deserialize: offset(%lu) larger then data block(%lu)", offset, d_length);
}
temp = (srm_value*) malloc (sizeof(srm_value));
memset (temp, 0x00, sizeof(srm_value));
@@ -484,7 +484,6 @@
skip = skip2;
break;
case SRM_VALUE_HASH:
- /* {FIX ME: Retrieve hash size too} */
skip2 = 8;
VALP_SET_HASH(temp);
/* Skip over type: */
Received on Wed Apr 10 22:22:04 2002
This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 12:00:02 CET