summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-02 23:30:58 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-02 23:30:58 +0100
commit061c93625c8c5c96b2a8059b167cc3f637c80bd7 (patch)
tree61291a9f4bd80acd63918971939a6aa0cd915b78 /src
parentc25fa6abad5893c052b05e2fd23d6fd8fee1a0cf (diff)
use separate message type to indicate end of transmission (much cleaner)
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_protocols.h6
-rw-r--r--src/namestore/gnunet-service-namestore.c10
-rw-r--r--src/namestore/namestore_api.c81
3 files changed, 70 insertions, 27 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 4831c9215..898ad6258 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1352,6 +1352,12 @@ extern "C"
*/
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP 448
+/**
+ * Service to client: end of list of results
+ */
+#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END 449
+
+
/*******************************************************************************
* LOCKMANAGER message types
******************************************************************************/
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 6ad7354ad..1b9e01e18 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -1733,7 +1733,7 @@ run_zone_iteration_round (struct ZoneIteration *zi,
{
struct ZoneIterationProcResult proc;
struct GNUNET_MQ_Envelope *env;
- struct RecordResultMessage *rrm;
+ struct GNUNET_NAMESTORE_Header *em;
struct GNUNET_TIME_Absolute start;
struct GNUNET_TIME_Relative duration;
@@ -1778,9 +1778,9 @@ run_zone_iteration_round (struct ZoneIteration *zi,
(unsigned long long) (limit - proc.limit),
(unsigned long long) limit);
/* send empty response to indicate end of list */
- env = GNUNET_MQ_msg (rrm,
- GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT);
- rrm->gns_header.r_id = htonl (zi->request_id);
+ env = GNUNET_MQ_msg (em,
+ GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END);
+ em->r_id = htonl (zi->request_id);
GNUNET_MQ_send (zi->nc->mq,
env);
GNUNET_CONTAINER_DLL_remove (zi->nc->op_head,
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 55745d83d..527576718 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -523,6 +523,7 @@ static int
check_record_result (void *cls,
const struct RecordResultMessage *msg)
{
+ static struct GNUNET_CRYPTO_EcdsaPrivateKey priv_dummy;
const char *name;
size_t msg_len;
size_t name_len;
@@ -543,12 +544,19 @@ check_record_result (void *cls,
return GNUNET_SYSERR;
}
name = (const char *) &msg[1];
- if ( (name_len > 0) &&
+ if ( (0 == name_len) ||
('\0' != name[name_len -1]) )
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
+ if (0 == memcmp (&msg->private_key,
+ &priv_dummy,
+ sizeof (priv_dummy)) )
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
return check_rd (rd_len,
&name[name_len],
ntohs (msg->rd_count));
@@ -566,7 +574,6 @@ static void
handle_record_result (void *cls,
const struct RecordResultMessage *msg)
{
- static struct GNUNET_CRYPTO_EcdsaPrivateKey priv_dummy;
struct GNUNET_NAMESTORE_Handle *h = cls;
struct GNUNET_NAMESTORE_QueueEntry *qe;
struct GNUNET_NAMESTORE_ZoneIterator *ze;
@@ -595,25 +602,6 @@ handle_record_result (void *cls,
force_reconnect (h);
return;
}
- if ( (0 == name_len) &&
- (0 == (memcmp (&msg->private_key,
- &priv_dummy,
- sizeof (priv_dummy)))) )
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Zone iteration completed!\n");
- if (NULL == ze)
- {
- GNUNET_break (0);
- force_reconnect (h);
- return;
- }
- if (NULL != ze->finish_cb)
- ze->finish_cb (ze->finish_cb_cls);
- free_ze (ze);
- return;
- }
-
name = (const char *) &msg[1];
rd_tmp = &name[name_len];
{
@@ -654,6 +642,51 @@ handle_record_result (void *cls,
/**
* Handle an incoming message of type
+ * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END
+ *
+ * @param cls
+ * @param msg the message we received
+ */
+static void
+handle_record_result_end (void *cls,
+ const struct GNUNET_NAMESTORE_Header *msg)
+{
+ struct GNUNET_NAMESTORE_Handle *h = cls;
+ struct GNUNET_NAMESTORE_QueueEntry *qe;
+ struct GNUNET_NAMESTORE_ZoneIterator *ze;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received RECORD_RESULT_END\n");
+ ze = find_zi (h,
+ ntohl (msg->r_id));
+ qe = find_qe (h,
+ ntohl (msg->r_id));
+ if ( (NULL == ze) &&
+ (NULL == qe) )
+ return; /* rid not found */
+ if ( (NULL != ze) &&
+ (NULL != qe) )
+ {
+ GNUNET_break (0); /* rid ambigous */
+ force_reconnect (h);
+ return;
+ }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Zone iteration completed!\n");
+ if (NULL == ze)
+ {
+ GNUNET_break (0);
+ force_reconnect (h);
+ return;
+ }
+ if (NULL != ze->finish_cb)
+ ze->finish_cb (ze->finish_cb_cls);
+ free_ze (ze);
+}
+
+
+/**
+ * Handle an incoming message of type
* #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
*
* @param qe the respective entry in the message queue
@@ -810,6 +843,10 @@ reconnect (struct GNUNET_NAMESTORE_Handle *h)
GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT,
struct RecordResultMessage,
h),
+ GNUNET_MQ_hd_fixed_size (record_result_end,
+ GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END,
+ struct GNUNET_NAMESTORE_Header,
+ h),
GNUNET_MQ_hd_var_size (lookup_result,
GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE,
struct LabelLookupResponseMessage,