Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Upgraded to C4.1 #21

Merged
merged 3 commits into from

2 participants

Pieter Hintjens stephen-wolf
Pieter Hintjens
Owner

No description provided.

stephen-wolf stephen-wolf merged commit d5f0491 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. Pieter Hintjens

    Upgraded to C4.1

    hintjens authored
Commits on Mar 26, 2013
  1. Pieter Hintjens

    Fixed issue #22

    hintjens authored
  2. Pieter Hintjens
This page is out of date. Refresh to see the latest.
2  README.md
View
@@ -37,7 +37,7 @@ This code needs the freshest possible libzmq and CZMQ. To build:
Contribution process:
- http://rfc.zeromq.org/spec:16
+ http://rfc.zeromq.org/spec:22
## Internals
4 include/fmq_msg.h
View
@@ -105,9 +105,7 @@ int
// Send the OHAI to the output in one step
int
- fmq_msg_send_ohai (void *output,
- char *protocol,
- byte version);
+ fmq_msg_send_ohai (void *output);
// Send the ORLY to the output in one step
int
4 model/fmq_server_sub.xml
View
@@ -86,8 +86,10 @@ sub_patch_add (sub_t *self, fmq_patch_t *patch)
}
existing = (fmq_patch_t *) zlist_next (self->client->patches);
}
+ if (fmq_patch_op (patch) == patch_create)
+ zhash_insert (self->cache,
+ fmq_patch_digest (patch), fmq_patch_virtual (patch));
// Track that we've queued patch for client, so we don't do it twice
- zhash_insert (self->cache, fmq_patch_digest (patch), fmq_patch_virtual (patch));
zlist_append (self->client->patches, fmq_patch_dup (patch));
}
</declare>
2  scripts/codec_c.gsl
View
@@ -106,7 +106,7 @@ int
// Send the $(message.NAME) to the output in one step
int
$(class.name)_send_$(name) (void *output\
-.for field
+.for field where !defined (value)
,
. if type = "number"
$(ctype) $(name)\
2  scripts/library.gsl
View
@@ -7,7 +7,7 @@
if defined (my.include_file)
move my.include_file after include
else
- preproc_error ("Error loading include file: $(filename): $(xml.error?)")
+ echo "E: error loading include file: $(filename): $(xml.error?)"
endif
else
echo "E: required attribute 'filename' not defined"
56 src/fmq_client.c
View
@@ -173,11 +173,11 @@ typedef enum {
start_state = 1,
requesting_access_state = 2,
subscribing_state = 3,
- ready_state = 4
+ ready_state = 4,
+ terminated_state = 5
} state_t;
typedef enum {
- terminate_event = -1,
initialize_event = 1,
srsly_event = 2,
rtfm_event = 3,
@@ -632,12 +632,6 @@ log_protocol_error (client_t *self, server_t *server)
puts ("E: protocol error");
}
-static void
-terminate_the_server (client_t *self, server_t *server)
-{
- server->next_event = terminate_event;
-}
-
// Execute state machine as long as we have events
static void
client_server_execute (client_t *self, server_t *server, int event)
@@ -657,18 +651,17 @@ client_server_execute (client_t *self, server_t *server, int event)
else
if (server->event == srsly_event) {
log_access_denied (self, server);
- terminate_the_server (self, server);
- server->state = start_state;
+ server->state = terminated_state;
}
else
if (server->event == rtfm_event) {
log_invalid_message (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
else {
// Process all other events
log_protocol_error (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
break;
@@ -689,13 +682,12 @@ client_server_execute (client_t *self, server_t *server, int event)
else
if (server->event == srsly_event) {
log_access_denied (self, server);
- terminate_the_server (self, server);
- server->state = start_state;
+ server->state = terminated_state;
}
else
if (server->event == rtfm_event) {
log_invalid_message (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
else {
// Process all other events
@@ -719,18 +711,17 @@ client_server_execute (client_t *self, server_t *server, int event)
else
if (server->event == srsly_event) {
log_access_denied (self, server);
- terminate_the_server (self, server);
- server->state = start_state;
+ server->state = terminated_state;
}
else
if (server->event == rtfm_event) {
log_invalid_message (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
else {
// Process all other events
log_protocol_error (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
break;
@@ -757,26 +748,35 @@ client_server_execute (client_t *self, server_t *server, int event)
else
if (server->event == srsly_event) {
log_access_denied (self, server);
- terminate_the_server (self, server);
- server->state = start_state;
+ server->state = terminated_state;
}
else
if (server->event == rtfm_event) {
log_invalid_message (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
}
else {
// Process all other events
log_protocol_error (self, server);
- terminate_the_server (self, server);
+ server->state = terminated_state;
+ }
+ break;
+
+ case terminated_state:
+ if (server->event == srsly_event) {
+ log_access_denied (self, server);
+ server->state = terminated_state;
+ }
+ else
+ if (server->event == rtfm_event) {
+ log_invalid_message (self, server);
+ server->state = terminated_state;
+ }
+ else {
+ // Process all other events
}
break;
- }
- if (server->next_event == terminate_event) {
- // Automatically calls server_destroy
- // reset state machine
- break;
}
}
}
4 src/fmq_msg.c
View
@@ -770,9 +770,7 @@ fmq_msg_send (fmq_msg_t **self_p, void *output)
int
fmq_msg_send_ohai (
- void *output,
- char *protocol,
- byte version)
+ void *output)
{
fmq_msg_t *self = fmq_msg_new (FMQ_MSG_OHAI);
return fmq_msg_send (&self, output);
34 src/fmq_server.c
View
@@ -325,8 +325,10 @@ sub_patch_add (sub_t *self, fmq_patch_t *patch)
}
existing = (fmq_patch_t *) zlist_next (self->client->patches);
}
+ if (fmq_patch_op (patch) == patch_create)
+ zhash_insert (self->cache,
+ fmq_patch_digest (patch), fmq_patch_virtual (patch));
// Track that we've queued patch for client, so we don't do it twice
- zhash_insert (self->cache, fmq_patch_digest (patch), fmq_patch_virtual (patch));
zlist_append (self->client->patches, fmq_patch_dup (patch));
}
@@ -892,8 +894,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else {
// Process all other events
fmq_msg_id_set (client->reply, FMQ_MSG_RTFM);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -904,8 +904,6 @@ server_client_execute (server_t *self, client_t *client, int event)
case checking_client_state:
if (client->event == friend_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_OHAI_OK);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -914,8 +912,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else
if (client->event == foe_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_SRSLY);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -925,8 +921,6 @@ server_client_execute (server_t *self, client_t *client, int event)
if (client->event == maybe_event) {
list_security_mechanisms (self, client);
fmq_msg_id_set (client->reply, FMQ_MSG_ORLY);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -947,8 +941,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else {
// Process all other events
fmq_msg_id_set (client->reply, FMQ_MSG_RTFM);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -976,8 +968,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else {
// Process all other events
fmq_msg_id_set (client->reply, FMQ_MSG_RTFM);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -989,8 +979,6 @@ server_client_execute (server_t *self, client_t *client, int event)
if (client->event == icanhaz_event) {
store_client_subscription (self, client);
fmq_msg_id_set (client->reply, FMQ_MSG_ICANHAZ_OK);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1004,8 +992,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else
if (client->event == hugz_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_HUGZ_OK);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1022,8 +1008,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else
if (client->event == heartbeat_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_HUGZ);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1040,8 +1024,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else {
// Process all other events
fmq_msg_id_set (client->reply, FMQ_MSG_RTFM);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1052,8 +1034,6 @@ server_client_execute (server_t *self, client_t *client, int event)
case dispatching_state:
if (client->event == send_chunk_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_CHEEZBURGER);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1062,8 +1042,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else
if (client->event == send_delete_event) {
fmq_msg_id_set (client->reply, FMQ_MSG_CHEEZBURGER);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1096,8 +1074,6 @@ server_client_execute (server_t *self, client_t *client, int event)
else {
// Process all other events
fmq_msg_id_set (client->reply, FMQ_MSG_RTFM);
- zclock_log ("Send message to client");
- fmq_msg_dump (client->reply);
fmq_msg_send (&client->reply, client->router);
client->reply = fmq_msg_new (0);
fmq_msg_address_set (client->reply, client->address);
@@ -1121,8 +1097,6 @@ server_client_message (server_t *self)
if (!request)
return; // Interrupted; do nothing
- zclock_log ("Received message from client");
- fmq_msg_dump (request);
char *hashkey = zframe_strhex (fmq_msg_address (request));
client_t *client = zhash_lookup (self->clients, hashkey);
if (client == NULL) {
@@ -1210,7 +1184,7 @@ int
fmq_server_test (bool verbose)
{
printf (" * fmq_server: ");
- printf ("\n");
+ fflush (stdout);
zctx_t *ctx = zctx_new ();
fmq_server_t *self;
Something went wrong with that request. Please try again.