- op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
- sizeof (struct GNUNET_MessageHeader));
- op->h = h;
- op->msg = (const struct GNUNET_MessageHeader *) &op[1];
- msg.size = htons (sizeof (msg));
- msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
- memcpy (&op[1], &msg, sizeof (msg));
- GNUNET_CONTAINER_DLL_insert (h->op_head,
- h->op_tail,
- op);
+ if ( (NULL == h->op_head) ||
+ (GNUNET_MESSAGE_TYPE_IDENTITY_START != ntohs (h->op_head->msg->type)) )
+ {
+ op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
+ sizeof (struct GNUNET_MessageHeader));
+ op->h = h;
+ op->msg = (const struct GNUNET_MessageHeader *) &op[1];
+ msg.size = htons (sizeof (msg));
+ msg.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_START);
+ memcpy (&op[1], &msg, sizeof (msg));
+ GNUNET_CONTAINER_DLL_insert (h->op_head,
+ h->op_tail,
+ op);
+ }