You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by se...@apache.org on 2008/03/08 20:48:55 UTC
svn commit: r635058 - in /webservices/axis2/trunk/c/tools/tcpmon:
include/tcpmon_entry.h src/entry.c src/tcpmon.c
Author: senaka
Date: Sat Mar 8 11:48:53 2008
New Revision: 635058
URL: http://svn.apache.org/viewvc?rev=635058&view=rev
Log:
Fixing mtom bug in TCPMon
Modified:
webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_entry.h
webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c
Modified: webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_entry.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_entry.h?rev=635058&r1=635057&r2=635058&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_entry.h (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_entry.h Sat Mar 8 11:48:53 2008
@@ -150,6 +150,12 @@
tcpmon_entry_t * entry,
const axutil_env_t * env);
+ int(
+ AXIS2_CALL
+ * get_data_length)(
+ tcpmon_entry_t * entry,
+ const axutil_env_t * env);
+
axis2_status_t(
AXIS2_CALL
* set_format_bit)(
@@ -206,6 +212,9 @@
#define TCPMON_ENTRY_GET_FORMAT_BIT(entry, env) \
((entry)->ops->get_format_bit(entry, env))
+
+#define TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) \
+ ((entry)->ops->get_data_length(entry, env))
/** @} */
Modified: webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/entry.c?rev=635058&r1=635057&r2=635058&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/entry.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/entry.c Sat Mar 8 11:48:53 2008
@@ -46,6 +46,7 @@
axis2_char_t *time_diff;
axis2_char_t *test_file_name;
int format_bit;
+ int data_length;
}
tcpmon_entry_impl_t;
@@ -109,6 +110,11 @@
int AXIS2_CALL tcpmon_entry_get_format_bit(
tcpmon_entry_t * entry,
const axutil_env_t * env);
+
+int AXIS2_CALL tcpmon_entry_get_data_length(
+ tcpmon_entry_t * entry,
+ const axutil_env_t * env);
+
axis2_status_t AXIS2_CALL tcpmon_entry_set_format_bit(
tcpmon_entry_t * entry,
const axutil_env_t * env,
@@ -144,6 +150,7 @@
entry_impl->sent_headers = NULL;
entry_impl->is_success = AXIS2_FALSE;
entry_impl->format_bit = 0;
+ entry_impl->data_length = 0;
entry_impl->entry.ops =
AXIS2_MALLOC(env->allocator, sizeof(tcpmon_entry_ops_t));
@@ -165,6 +172,7 @@
entry_impl->entry.ops->is_success = tcpmon_entry_is_success;
entry_impl->entry.ops->set_format_bit = tcpmon_entry_set_format_bit;
entry_impl->entry.ops->get_format_bit = tcpmon_entry_get_format_bit;
+ entry_impl->entry.ops->get_data_length = tcpmon_entry_get_data_length;
return &(entry_impl->entry);
}
@@ -359,6 +367,20 @@
return entry_impl->format_bit;
}
+int AXIS2_CALL
+tcpmon_entry_get_data_length(
+ tcpmon_entry_t * entry,
+ const axutil_env_t * env)
+{
+ tcpmon_entry_impl_t *entry_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ entry_impl = AXIS2_INTF_TO_IMPL(entry);
+
+ return entry_impl->data_length;
+}
+
axis2_status_t AXIS2_CALL
tcpmon_entry_set_format_bit(
tcpmon_entry_t * entry,
@@ -490,6 +512,7 @@
entry_impl->sent_headers = headers;
entry_impl->sent_data = content;
+ entry_impl->data_length = buffer_size;
if (on_new_entry)
{
@@ -579,6 +602,7 @@
entry_impl->arrived_headers = headers;
entry_impl->arrived_data = content;
+ entry_impl->data_length = buffer_size;
if (buffer == NULL || buffer_size == 0)
{
entry_impl->is_success = 0;
@@ -761,7 +785,7 @@
}
else
{
- *(buffer + read_size - 1) = ' ';
+ /**(buffer + read_size - 1) = ' ';*/
}
}
}
@@ -785,7 +809,38 @@
body_ptr = buffer + header_width;
if (body_ptr && *body_ptr)
{
- *data = (axis2_char_t *) axutil_strdup(env, body_ptr);
+ if (mtom_optimized)
+ {
+ int count = read_size - strlen(header_ptr) - 4;
+ int copied = 0;
+ int plen = 0;
+ axis2_char_t *temp = NULL;
+ temp = AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_char_t) * count + 1);
+ while(count > copied)
+ {
+ plen = 0;
+ plen = ((int)strlen(body_ptr) + 1);
+ if (plen != 1)
+ {
+ sprintf(temp, "%s", body_ptr);
+ }
+ copied += plen;
+ if (count > copied)
+ {
+ temp += plen;
+ body_ptr += plen;
+ }
+ }
+ copied -= plen;
+ temp -= copied;
+ temp[count] = '\0';
+ *data = temp;
+ }
+ else
+ {
+ *data = (axis2_char_t *) axutil_strdup(env, body_ptr);
+ }
}
body_ptr = NULL;
}
@@ -824,7 +879,6 @@
int size = 0;
if (filename)
{
-
FILE *fp = fopen(filename, "a+");
size = (int)fwrite(buffer, 1, strlen(buffer), fp);
/* We are sure that the difference lies within the int range */
Modified: webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c?rev=635058&r1=635057&r2=635058&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c Sat Mar 8 11:48:53 2008
@@ -253,6 +253,12 @@
plain_buffer = TCPMON_ENTRY_SENT_DATA(entry, env);
if (plain_buffer) /* this can be possible as no xml present */
{
+ if (TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) ==
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env)) +
+ strlen(plain_buffer) + 4)
+ {
+ format = 0; /* mtom scenario */
+ }
formated_buffer = tcpmon_util_format_as_xml
(env, plain_buffer, format);
}
@@ -265,8 +271,62 @@
printf("/* sending time = %s*/\n", TCPMON_ENTRY_SENT_TIME(entry, env));
printf("---------------------\n");
- printf("%s\n\n%s\n\n", TCPMON_ENTRY_SENT_HEADERS(entry, env),
- formated_buffer);
+ if (format || TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) ==
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env)) +
+ strlen(formated_buffer) + 4)
+ {
+ printf("%s\n\n%s\n\n", TCPMON_ENTRY_SENT_HEADERS(entry, env),
+ formated_buffer);
+ }
+ else
+ {
+ /*int count = 0;
+ int printed = 0;
+ axis2_char_t *temp = NULL;
+ axis2_char_t *formated_buffer_temp = formated_buffer;
+ printf("%s\n", TCPMON_ENTRY_SENT_HEADERS(entry, env));
+ count = TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) - 4 -
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env));
+ temp = AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_char_t) * count + 1);
+ while (count > printed)
+ {
+ if (*formated_buffer)
+ {
+ temp[printed] = *formated_buffer;
+ }
+ else
+ {
+ temp[printed] = ' ';
+ }
+ printed++;
+ formated_buffer++;
+ }
+ temp[count] = '\0';
+ printf("%s\n\n", temp);
+ AXIS2_FREE(env->allocator, temp);
+ formated_buffer = formated_buffer_temp;*/
+ int count = 0;
+ int printed = 0;
+ printf("%s\n", TCPMON_ENTRY_SENT_HEADERS(entry, env));
+ count = TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) - 4 -
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env));
+ while (count > printed)
+ {
+ int plen = 0;
+ plen = ((int)strlen(formated_buffer) + 1);
+ if (plen != 1)
+ {
+ printf("%s", formated_buffer);
+ }
+ printed += plen;
+ if (count > printed)
+ {
+ printf("%c", '\0');
+ formated_buffer += plen;
+ }
+ }
+ }
/* 2 file */
fprintf(file, "%s\n", "SENDING DATA..");
@@ -283,13 +343,39 @@
}
if (strcmp(formated_buffer, "") != 0)
{
- convert = axutil_strdup(env, formated_buffer);
- convert = str_replace(convert, "; ", ";\n\t");
- convert = str_replace(convert, "><", ">\n<");
- fprintf(file, "%s", convert);
- if (convert)
+ if (format || TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) ==
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env)) +
+ strlen(formated_buffer) + 4)
+ {
+ convert = axutil_strdup(env, formated_buffer);
+ convert = str_replace(convert, "><", ">\n<");
+ fprintf(file, "%s", convert);
+ if (convert)
+ {
+ free(convert);
+ }
+ }
+ else
{
- free(convert);
+ int count = 0;
+ int printed = 0;
+ count = TCPMON_ENTRY_GET_DATA_LENGTH(entry, env) - 4 -
+ strlen(TCPMON_ENTRY_SENT_HEADERS(entry, env));
+ while (count > printed)
+ {
+ int plen = 0;
+ plen = ((int)strlen(formated_buffer) + 1);
+ if (plen != 1)
+ {
+ fprintf(file, "%s", formated_buffer);
+ }
+ printed += plen;
+ if (count > printed)
+ {
+ fprintf(file, "%c", '\0');
+ formated_buffer += plen;
+ }
+ }
}
}
}
@@ -306,7 +392,7 @@
formated_buffer = "";
}
/* 2 screen */
- printf("%s\n", "RETRIEVING DATA..");
+ printf("\n\n%s\n", "RETRIEVING DATA..");
printf("/* retrieving time = %s*/\n",
TCPMON_ENTRY_ARRIVED_TIME(entry, env));
printf("/* time throughput = %s*/\n",
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org