Skip to content

Instantly share code, notes, and snippets.

@hintjens
Created May 3, 2011 14:54
Show Gist options
  • Save hintjens/953473 to your computer and use it in GitHub Desktop.
Save hintjens/953473 to your computer and use it in GitHub Desktop.
Diffs from 1.3d0 to 1.3d1
Index: asl/asl_client_session.gsl
===================================================================
--- asl/asl_client_session.gsl (revision 12077)
+++ asl/asl_client_session.gsl (revision 12145)
@@ -609,7 +609,7 @@
<private name = "header">
static int
- s_wait_for_methods ($\(selftype) *self, int timeout, Bool blocking, Bool on_content);
+ s_wait_for_methods ($\(selftype) *self, int timeout, Bool blocking, Bool want_content);
static void
s_process_chrono ($\(selftype) *self, $(protocol.name)_content_basic_t *content);
static void
@@ -627,7 +627,7 @@
$\(selftype) *self,
int timeout,
Bool blocking,
- Bool on_content)
+ Bool want_content)
{
smt_method_t
*smt_method = NULL;
@@ -635,17 +635,24 @@
*proto_method;
int
rc = 0; // OK by default
+ qbyte
+ pending; // Size of method queue
+ Bool
+ got_content = FALSE; // Did we get 1+ contents?
- assert (!self->method_queue->zombie);
+ smt_method_queue_t
+ *smt_queue = smt_method_queue_link (self->method_queue);
+ assert (!smt_queue->zombie);
FOREVER {
smt_method_unlink (&smt_method);
if (timeout >= 0)
- smt_method_queue_wait (self->method_queue, timeout);
- smt_method = smt_method_queue_pop (self->method_queue);
+ smt_method_queue_wait (smt_queue, timeout);
+ smt_method = smt_method_queue_pop (smt_queue);
+ pending = smt_queue->count;
// If we don't have a method, we timed-out
if (!smt_method) {
if (blocking) {
- if (self->method_queue->zombie)
+ if (smt_queue->zombie)
self->error_text = "No reply - method queue destroyed";
else
self->error_text = "No reply received - timeout";
@@ -676,8 +683,10 @@
proto_method = ($(basename)_method_t *) smt_method->data;
if (proto_method) {
$(basename)_method_execute (proto_method, self->connection, self);
+ if (proto_method->content)
+ got_content = TRUE;
if (proto_method->sync
- || (proto_method->content && on_content))
+ || (got_content && want_content && pending == 0))
break; // Got synchronous method, end
}
else
@@ -706,7 +715,7 @@
if (smt_method->result == $(BASENAME)_REPLY_DIRECT_MSG) {
self_push_arrived (
self, ($(protocol.name)_content_basic_t *) smt_method->data, NULL, NULL, NULL, 0);
- if (on_content)
+ if (want_content && pending == 0)
break; // We were waiting for content
}
else {
@@ -714,6 +723,7 @@
icl_console_print ("E: invalid reply result %d", smt_method->result);
}
}
+ smt_method_queue_unlink (&smt_queue);
smt_method_unlink (&smt_method);
return (rc);
}
Index: asl/asl_content_class.gsl
===================================================================
--- asl/asl_content_class.gsl (revision 12077)
+++ asl/asl_content_class.gsl (revision 12145)
@@ -397,7 +397,7 @@
remainder = (size_t) self->body_size - reader->processed;
if (remainder > 0) {
bucket = ipr_bucket_new (0);
- bucket->cur_size = min (reader->frame_max, remainder);
+ bucket->cur_size = MIN (reader->frame_max, remainder);
bucket->data = self->body_data + reader->processed;
reader->processed += bucket->cur_size;
reader->count++;
@@ -419,7 +419,7 @@
remainder = (size_t) from_bucket->cur_size - reader->processed;
if (remainder > 0) {
bucket = ipr_bucket_new (0);
- bucket->cur_size = min (reader->frame_max, remainder);
+ bucket->cur_size = MIN (reader->frame_max, remainder);
bucket->data = from_bucket->data + reader->processed;
reader->processed += bucket->cur_size;
reader->count++;
@@ -881,7 +881,7 @@
msecs = 0; // Ignore/truncate overflows
icl_shortstr_fmt (deltas + strlen (deltas),
- "%s%d", delim, max (msecs - previous, 0));
+ "%s%d", delim, MAX (msecs - previous, 0));
delim = " ";
previous = msecs;
}
Index: icl/base.h
===================================================================
--- icl/base.h (revision 12077)
+++ icl/base.h (revision 12145)
@@ -407,9 +407,9 @@
#define randomof(num) (int) (((float) num) * rand () / (RAND_MAX + 1.0))
#define randomize() srand ((uint) apr_time_usec (apr_time_now ()))
-#if (!defined (min))
-# define min(a,b) (((a) < (b))? (a): (b))
-# define max(a,b) (((a) > (b))? (a): (b))
+#if (!defined (MIN))
+# define MIN(a,b) (((a) < (b))? (a): (b))
+# define MAX(a,b) (((a) > (b))? (a): (b))
#endif
//- Assertion that pointer value is as expect -------------------------------
Index: ipr/ipr_bits.icl
===================================================================
--- ipr/ipr_bits.icl (revision 12077)
+++ ipr/ipr_bits.icl (revision 12145)
@@ -205,7 +205,7 @@
assert (source);
assert (source->size <= IPR_BITS_SIZE);
- data_size = min (self->size, source->size);
+ data_size = MIN (self->size, source->size);
for (cur_size = 0; cur_size < data_size; cur_size += sizeof (int64_t))
*(int64_t *) (self->data + cur_size) &= *(int64_t *) (source->data + cur_size);
@@ -225,7 +225,7 @@
assert (source);
assert (source->size <= IPR_BITS_SIZE);
- data_size = max (self->size, source->size);
+ data_size = MAX (self->size, source->size);
for (cur_size = 0; cur_size < data_size; cur_size += sizeof (int64_t))
*(int64_t *) (self->data + cur_size) |= *(int64_t *) (source->data + cur_size);
@@ -245,7 +245,7 @@
assert (source);
assert (source->size <= IPR_BITS_SIZE);
- data_size = max (self->size, source->size);
+ data_size = MAX (self->size, source->size);
for (cur_size = 0; cur_size < data_size; cur_size += sizeof (int64_t))
*(int64_t *) (self->data + cur_size) ^= *(int64_t *) (source->data + cur_size);
Index: ipr/ipr_stat.icl
===================================================================
--- ipr/ipr_stat.icl (revision 12077)
+++ ipr/ipr_stat.icl (revision 12145)
@@ -70,8 +70,8 @@
</local>
//
self->sum += value;
- self->min = self->count? min (value, self->min): value;
- self->max = max (value, self->max);
+ self->min = self->count? MIN (value, self->min): value;
+ self->max = MAX (value, self->max);
self->count++;
delta = value - self->mean;
Index: ipr/ipr_time.icl
===================================================================
--- ipr/ipr_time.icl (revision 12077)
+++ ipr/ipr_time.icl (revision 12145)
@@ -72,7 +72,7 @@
char
fraction [8];
char
- time_zone [8];
+ time_zone [12];
</local>
//
if (utc) {
Index: server/amq_console.icl
===================================================================
--- server/amq_console.icl (revision 12077)
+++ server/amq_console.icl (revision 12145)
@@ -257,22 +257,24 @@
ipr_xml_attr_set (cml_item, "version", "1.0");
ipr_xml_attr_set (cml_item, "xmlns", "http://www.openamq.org/schema/cml");
- cur_item = ipr_xml_new (cml_item, name, NULL);
- ipr_xml_attr_set (cur_item, "class", entry->class_ref->name);
- ipr_xml_attr_set (cur_item, "object", icl_shortstr_fmt (strvalue, "%d", object_id));
- ipr_xml_attr_set (cur_item, "status", "ok");
- if (notice)
- ipr_xml_attr_set (cur_item, "notice", notice);
+ if (entry) {
+ cur_item = ipr_xml_new (cml_item, name, NULL);
+ ipr_xml_attr_set (cur_item, "class", entry->class_ref->name);
+ ipr_xml_attr_set (cur_item, "object", icl_shortstr_fmt (strvalue, "%d", object_id));
+ ipr_xml_attr_set (cur_item, "status", "ok");
+ if (notice)
+ ipr_xml_attr_set (cur_item, "notice", notice);
- if (fields) {
- field = asl_field_list_first (fields);
- while (field) {
- sub_item = ipr_xml_new (cur_item, "field", NULL);
- ipr_xml_attr_set (sub_item, "name", field->name);
- val_item = ipr_xml_new (sub_item, NULL, asl_field_string (field));
- ipr_xml_unlink (&val_item);
- ipr_xml_unlink (&sub_item);
- field = asl_field_list_next (&field);
+ if (fields) {
+ field = asl_field_list_first (fields);
+ while (field) {
+ sub_item = ipr_xml_new (cur_item, "field", NULL);
+ ipr_xml_attr_set (sub_item, "name", field->name);
+ val_item = ipr_xml_new (sub_item, NULL, asl_field_string (field));
+ ipr_xml_unlink (&val_item);
+ ipr_xml_unlink (&sub_item);
+ field = asl_field_list_next (&field);
+ }
}
}
s_reply_xml (request, cml_item);
@@ -313,11 +315,12 @@
ipr_xml_attr_set (cml_item, "version", "1.0");
ipr_xml_attr_set (cml_item, "xmlns", "http://www.openamq.org/schema/cml");
- cur_item = ipr_xml_new (cml_item, name, NULL);
- ipr_xml_attr_set (cur_item, "class", entry->class_ref->name);
- ipr_xml_attr_set (cur_item, "object", icl_shortstr_fmt (strvalue, "%d", object_id));
- ipr_xml_attr_set (cur_item, "status", status);
-
+ if (entry) {
+ cur_item = ipr_xml_new (cml_item, name, NULL);
+ ipr_xml_attr_set (cur_item, "class", entry->class_ref->name);
+ ipr_xml_attr_set (cur_item, "object", icl_shortstr_fmt (strvalue, "%d", object_id));
+ ipr_xml_attr_set (cur_item, "status", status);
+ }
s_reply_xml (request, cml_item);
ipr_xml_unlink (&cur_item);
ipr_xml_destroy (&cml_item);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment