コード例 #1
0
ファイル: v_groupStream.c プロジェクト: xrl/opensplice_dds
static c_bool
isGroupConnected(
    v_group group,
    c_voidp args)
{
    struct groupConnected* data;

    assert(C_TYPECHECK(group, v_group));

    data = (struct groupConnected*)args;

    if(strcmp(v_partitionName(group->partition),
              v_partitionName(data->group->partition)) == 0){
        if(strcmp(v_topicName(group->topic),
                  v_topicName(data->group->topic)) == 0){
            data->connected = TRUE;
        }
    }
    return (!data->connected);
}
コード例 #2
0
static v_networkHashValue
v_networkReaderEntryCalculateHashValue(
    v_networkReaderEntry entry)
{
    v_networkHashValue result = {0xa0, 0x22, 0x8d, 0x07};

    const char *partitionName;
    const char *topicName;
    const char *currentPtr;

    partitionName = v_partitionName(v_groupPartition(entry->group));
    topicName = v_topicName(v_groupTopic(entry->group));
    currentPtr = partitionName;

    while (*currentPtr != '\0') {
        /* gcc2.96 gave internal compile errrors (with optimisation enabled)
         * when compiling the NW_ROT_CHAR macro twice in same command :
         * these assignments are deliberatly split over 2 lines as workaround.
         */

        result.h1 = NW_ROT_CHAR(result.h1, 1);
        result.h1 += NW_ROT_CHAR(*currentPtr, 4);

        result.h2 = NW_ROT_CHAR(result.h2, 2);
        result.h2 += NW_ROT_CHAR(*currentPtr, 7);

        result.h3 = NW_ROT_CHAR(result.h3, 3);
        result.h3 += NW_ROT_CHAR(*currentPtr, 1);

        result.h4 = NW_ROT_CHAR(result.h4, 4);
        result.h4 += NW_ROT_CHAR(*currentPtr, 5);

        currentPtr = &(currentPtr[1]);
    }

    currentPtr = topicName;
    while (*currentPtr != '\0') {
        result.h1 = NW_ROT_CHAR(result.h1, 4);
        result.h1 += NW_ROT_CHAR(*currentPtr, 7);

        result.h2 = NW_ROT_CHAR(result.h2, 3);
        result.h2 += NW_ROT_CHAR(*currentPtr, 1);

        result.h3 = NW_ROT_CHAR(result.h3, 2);
        result.h3 += NW_ROT_CHAR(*currentPtr, 5);

        result.h4 = NW_ROT_CHAR(result.h4, 1);
        result.h4 += NW_ROT_CHAR(*currentPtr, 4);

        currentPtr = &(currentPtr[1]);
    }
    return result;
}
コード例 #3
0
ファイル: v_partition.c プロジェクト: xrl/opensplice
c_iter
v_partitionLookupSubscribers(
    v_partition partition)
{
    c_iter participants;
    c_iter result;
    c_iter entities;
    c_iter partitions;
    v_participant participant;
    v_entity entity;
    v_entity partition2;

    result = NULL;
    participants = v_resolveParticipants(v_objectKernel(partition), "*");
    participant = v_participant(c_iterTakeFirst(participants));

    while (participant != NULL) {
        c_lockRead(&participant->lock);
        entities = c_select(participant->entities, 0);
        c_lockUnlock(&participant->lock);
        entity = v_entity(c_iterTakeFirst(entities));

        while (entity != NULL) {
            if(v_objectKind(entity) == K_SUBSCRIBER) {
                partitions = v_subscriberLookupPartitions(v_subscriber(entity),
                                                    v_partitionName(partition));

                if (c_iterLength(partitions) > 0) {
                    result = c_iterInsert(result, entity); /* transfer refcount */
                } else {
                    c_free(entity);
                }
                partition2 = v_entity(c_iterTakeFirst(partitions));

                while (partition2 != NULL) {
                    c_free(partition2);
                    partition2 = v_entity(c_iterTakeFirst(partitions));
                }
                c_iterFree(partitions);
            }
            /* entity is already free or refcount transferred to result */
            entity = v_entity(c_iterTakeFirst(entities));
        }
        c_iterFree(entities);
        c_free(participant);
        participant = v_participant(c_iterTakeFirst(participants));
    }
    c_iterFree(participants);
    return result;
}
コード例 #4
0
static c_bool
checkPartitionInterest(
    c_object o,
    c_voidp arg)
{
    v_partitionInterest partitionInterest = (v_partitionInterest)o;
    v_partition partition = v_partition(arg);
    c_bool result = TRUE;

    if (v_partitionStringMatchesExpression(v_partitionName(partition), partitionInterest->expression)) {
        result = FALSE;
    }

    return result;
}
コード例 #5
0
ファイル: nw_channel.c プロジェクト: xrl/opensplice
void
nw_receiveChannelAddGroup(
    nw_receiveChannel channel,
    v_networkReaderEntry entry)
{
    NW_CONFIDENCE(channel != NULL);

    if (channel != NULL) {
        /* Add entry to hashtable */
        nw_entryHashInsert(channel->hash, entry);
        NW_TRACE_3(Groups, 2,
                   "Channel %u added new group with partition %s and topic %s",
                   ((nw_channel)(channel))->channelId,
                   v_partitionName(v_groupPartition(entry->group)),
                   v_topicName(v_groupTopic(entry->group)));
    }
}
コード例 #6
0
ファイル: nw_channel.c プロジェクト: xrl/opensplice
static void
nw_entryHashInsert(
    nw_entryHash entryHash,
    v_networkReaderEntry entry)
{
    nw_entryHashItem *itemPtr;
    nw_bool ready = FALSE;
    int cmpRes;
    const c_char *partitionName;
    const c_char *topicName;

    partitionName = v_partitionName(v_groupPartition(entry->group));
    topicName = v_topicName(v_groupTopic(entry->group));
    itemPtr = &NW_ITEM_FROM_HASHVALUE(entryHash, entry->hashValue);
    while ((*itemPtr != NULL) && !ready) {
        cmpRes = strcmp((*itemPtr)->topicName, topicName);
        if (cmpRes == 0) {
            cmpRes = strcmp((*itemPtr)->partitionName, partitionName);
            if (cmpRes == 0) {
                ready = TRUE;
            } else if (cmpRes < 0) {
                itemPtr = &((*itemPtr)->next);
            } else {
                /* No entry was found and no entry will be found, insert new */
                nw_entryHashItemInsert(entry->hashValue, partitionName, topicName,
                                       entry, itemPtr);
                ready = TRUE;
            }
        } else if (cmpRes < 0) {
            itemPtr = &((*itemPtr)->next);
        } else {
            /* No entry found, and will not be found */
            nw_entryHashItemInsert(entry->hashValue, partitionName, topicName,
                                   entry, itemPtr);
            ready = TRUE;
        }
    }

    if (!ready) {
        /* No proper place found, we are at the tail now */
        nw_entryHashItemInsert(entry->hashValue, partitionName, topicName,
            entry, itemPtr);
    }
}
コード例 #7
0
ファイル: nw_channel.c プロジェクト: xrl/opensplice
c_ulong
nw_sendChannelWrite(
    nw_sendChannel sendChannel,
    v_networkReaderEntry entry,
    v_message message,
    nw_signedLength *maxBytes,
    plugSendStatistics pss)
{
    c_ulong result = 0;
    nw_channel channel = (nw_channel)sendChannel;

    NW_CONFIDENCE(channel);

    result = nw_bridgeWrite(channel->owningBridge, channel->channelId,
                            entry->networkPartitionId, message, entry->hashValue,
                            v_partitionName(v_groupPartition(entry->group)),
                            v_topicName(v_groupTopic(entry->group)),maxBytes, pss);

    return result;
}
コード例 #8
0
ファイル: d_misc.c プロジェクト: xrl/opensplice_dds
void
d_reportLocalGroup(
    d_durability d,
    const char *threadName,
    v_group group)
{
    const c_char* durability;
    v_topicQos qos;

    if(group){
        qos = v_topicQosRef(group->topic);
        switch(qos->durability.kind){
            case V_DURABILITY_VOLATILE:
                durability = "VOLATILE";
                break;
            case V_DURABILITY_TRANSIENT_LOCAL:
                durability = "TRANSIENT LOCAL";
                break;
            case V_DURABILITY_TRANSIENT:
                durability = "TRANSIENT";
                break;
            case V_DURABILITY_PERSISTENT:
                durability = "PERSISTENT";
                break;
            default:
                durability = "<<UNKNOWN>>";
                assert(FALSE);
                break;
        }
    } else {
        durability = "<<UNKNOWN>>";
        assert(FALSE);
    }
    d_printTimedEvent(d, D_LEVEL_FINE,
                      threadName, "Group found: %s.%s (%s)\n",
                      v_partitionName(v_groupPartition(group)),
                      v_topicName(v_groupTopic(group)),
                      durability);
}
コード例 #9
0
ファイル: v_networkReader.c プロジェクト: osrf/opensplice
c_bool
v_networkReaderWrite(
    v_networkReader reader,
    v_message message,
    v_networkReaderEntry entry,
    c_ulong sequenceNumber,
    v_gid sender,
    c_bool sendTo, /* for p2p writing */
    v_gid receiver)
{
    c_bool result;
    v_networkQueue bestQueue;

    assert(reader != NULL);
    assert(C_TYPECHECK(reader, v_networkReader));

    /* First select the best queue */
    if (reader->remoteActivity && !(pa_ld32(&v_objectKernel(reader)->isolate) & V_ISOLATE_MUTE)) {
        if (message != NULL) {
            bestQueue = v_networkReaderSelectBestQueue(
                            reader,
                            message->qos,
                            sendTo,
                            v_partitionName(v_group(entry->group)->partition),
                            v_topicName(v_groupTopic(entry->group)));
        } else {
            bestQueue = reader->defaultQueue;
        }
        result = v_networkQueueWrite(bestQueue, message, entry,
                                     sequenceNumber, sender, sendTo, receiver);
    } else {
        result = TRUE;
    }

    return result;
}
コード例 #10
0
ファイル: v_groupStream.c プロジェクト: S73417H/opensplice
void
v_groupStreamNotify(
    v_groupStream stream,
    v_event e,
    c_voidp userData)
{
    struct groupConnected data;
    c_iter partitions;
    c_bool interested;
    v_partition partition, found;

    OS_UNUSED_ARG(userData);
    assert(stream != NULL);
    assert(C_TYPECHECK(stream,v_groupStream));
    if (e) {
        if (e->kind == V_EVENT_NEW_GROUP) {
            v_observerLock(v_observer(stream));

            /*
             * Check if group fits interest. This extra steps are needed because
             * the groupActionStream does not create the groups that match the
             * subscriber qos partition expression on creation. It only needs to
             * connect to new groups once they are created. This is a different
             * approach then for a data reader.
             */
            partition = v_group(e->userData)->partition;

            /*
             * Because already existing partitions are created and added to the
             * subscriber of the groupActionStream at creation time, these
             * partitions can be resolved from the subscriber. This is necessary to
             * determine whether the groupActionStream should connect to the new
             * group or if it is already connected.
             */
            partitions = v_subscriberLookupPartitions(v_reader(stream)->subscriber,
                                                   v_partitionName(partition));
            interested = FALSE;
            found = v_partition(c_iterTakeFirst(partitions));

            while(found){
                if(interested == FALSE){
                    if(strcmp(v_partitionName(partition),
                              v_partitionName(found)) == 0){
                        interested = TRUE;
                    }
                }
                c_free(found);
                found = v_partition(c_iterTakeFirst(partitions));
            }
            c_iterFree(partitions);

            if(interested == TRUE){
                /*
                 * This means the group is interesting for this
                 * groupActionStream. Now I have to check if the stream is already
                 * connected to this group, because we wouldn't want to connect
                 * multiple times to one single group.
                 */
                data.connected = FALSE;
                data.group     = v_group(e->userData);

                c_walk(stream->groups, (c_action)isGroupConnected, &data);

                if(data.connected == FALSE){
                    /*
                     * The stream is not connected to the group yet, so connect now.
                     */
                    v_groupStreamSubscribeGroup(stream, v_group(e->userData));
                }
            }
            v_observerUnlock(v_observer(stream));
        }
    }
    return;
}
コード例 #11
0
ファイル: nw_channelWriter.c プロジェクト: xrl/opensplice
static void
nw_channelWriterMain(
    v_entity e,
    c_voidp arg)
{
    v_networkReader reader;
    nw_channelWriter channelWriter;
    c_bool newGroupAvailable;
    v_networkQueue qosQueue;

    v_networkReaderWaitResult waitResult;
    c_long bytesWritten;
    /* Total number of messages sent to the network */
    c_ulong writtenCountMessages;
    /* Total number of bytes sent to the network */
    c_ulong writtenCountBytes;
    /* Total number of bytes sent to the network during one burst */
    c_ulong writtenCountBytesThisBurst;
    /* Number of message sent to the network after last report */
    c_ulong writtenCountMessagesReport;

    v_message message;
    v_networkReaderEntry entry;
    c_ulong sequenceNumber;
    v_gid sender;
    c_bool sendTo;
    v_gid receiver;
    c_time sendBefore;
    c_ulong priority;
    c_bool more = TRUE;
    c_bool slowingDown;
    c_ulong timeoutCount;
    nw_signedLength credits;
    v_networking n;
    NW_STRUCT(plugSendStatistics) pss = {0,0,0,0,0,0,0,0,0,0,
                                         {0,
                                          {{0,0},
                                           0},
                                          {{0,0},
                                           0},
                                          {0.0,0}},
                                         {0,
                                          {{0,0},
                                           0},
                                          {{0,0},
                                           0},
                                          {0.0,0}},
                                         0,0,0};
    v_fullCounterInit(&(pss.adminQueueAcks));
    v_fullCounterInit(&(pss.adminQueueData));

    reader = v_networkReader(e);
    channelWriter = (nw_channelWriter)arg;


    /* This line is needed as long as the discovery channel is not yet implemented */
    writtenCountBytesThisBurst = 0;
    writtenCountMessages = 0;
    writtenCountBytes = 0;
    writtenCountMessagesReport = 0;
    slowingDown = FALSE;
    timeoutCount = 0;
    credits = 0;

    while (!(int)nw_runnableTerminationRequested((nw_runnable)channelWriter)) {

        /* Wait for data on the reader */
        if (!slowingDown) {
            waitResult = v_networkReaderWait(reader,
                                             channelWriter->queueId,
                                             &qosQueue);
        } else {
            waitResult = v_networkReaderWaitDelayed(reader,
                 channelWriter->queueId, &qosQueue);

            NW_CONFIDENCE(waitResult & (V_WAITRESULT_TIMEOUT | V_WAITRESULT_TRIGGERED));
        }

        if ((waitResult & V_WAITRESULT_TRIGGERED) &&
            (!nw_runnableTerminationRequested((nw_runnable)channelWriter))) {
            /* If necessary, check if any new groups need to be added */
            newGroupAvailable = nw_channelUserRetrieveNewGroup(
                (nw_channelUser)channelWriter, &entry);

            while (newGroupAvailable) {
                /* Create a new channel on the network */
                /* No, do not call any function. With the new design,
                 * a channelWriter does not need to know anything about this
                 * new group. Maybe at a later stage. */
                /* nw_channelAddGroup((nw_channel)channelWriter->sendChannel, entry); */
                /* And notify we are connected */
                v_networkReaderEntryNotifyConnected(entry,channelWriter->serviceName);

                newGroupAvailable = nw_channelUserRetrieveNewGroup(
                     (nw_channelUser)channelWriter, &entry);
            }
        }

        /* Resend data should also obey max_burst_size
         * Each clocktick, the remaining credits of the last period and a
         * third of the new max_burst_size budget may be used for resend data.
         * The rest of the budget is assigned after that, and can be used to
         * flush stored buffers of send fresh data.
         */
        if (waitResult & V_WAITRESULT_TIMEOUT) {

            /*
             * The periodic action is needed for every clocktick.
             * This will also update the credits, for the amount of bandwidth
             * available in the coming period.
             */
            /*stat update routine */
            n = v_networking(v_subscriber(v_reader(reader)->subscriber)->participant);
            /* update statistics */
            if (v_entity(n)->statistics) {
                if (!pss.enabled) {
                    pss.enabled =1;
                }
                /* sync plug stats */
                nw_updatePlugSendStatistics(&pss,channelWriter);
                nw_SendChannelUpdate(v_networkingStatistics(v_entity(n)->statistics)->channels[channelWriter->stat_channel_id],channelWriter->scs);
            }

            nw_sendChannelPeriodicAction(channelWriter->sendChannel,&credits,&pss); /*struc call*/
            /* A flush is needed if we are slowing down. */
            if (slowingDown) {
                /* The return value is true is all data has been sent.
                 * Afterwards, credits will contain the new amount of allowed
                 * bytes.
                 * We are using a special flush function here that flushes full
                 * buffers only */
                slowingDown = !nw_sendChannelFlush(channelWriter->sendChannel,
                                                   FALSE, &credits, &pss);
            }
        }
        if ((waitResult & V_WAITRESULT_MSGWAITING) && !slowingDown) {
            /* Messages are waiting... */
            writtenCountBytesThisBurst = 0;
            more= TRUE;
            while (more &&
                  ((nw_signedLength)writtenCountBytesThisBurst <= credits))
            {
                /* Take any new messages */
                v_networkQueueTakeFirst(qosQueue, &message, &entry,
                    &sequenceNumber, &sender, &sendTo, &receiver,
                    &sendBefore, &priority, &more);
                NW_CONFIDENCE(message != NULL);
                NW_CONFIDENCE(entry != NULL);


		if (!(NW_SECURITY_CHECK_FOR_PUBLISH_PERMISSION_OF_SENDER_ON_SENDER_SIDE(entry))) {
				bytesWritten = 0; /* indicates that nothing has been written */

				NW_REPORT_WARNING_2(
						"nw_channelWriterMain",
						"Channel \"%s\" could not deliver message 0x%x : message dropped!",
						((nw_runnable)channelWriter)->name,
						message);
		} else {
				bytesWritten = nw_sendChannelWrite(channelWriter->sendChannel,
                                                   entry, message, &credits ,&pss); /* stat struc plug vars */
                if (bytesWritten == 0) {
                    NW_REPORT_WARNING_2(
                        "nw_channelWriterMain",
                        "Channel \"%s\" could not deliver message 0x%x : message dropped!",
                         ((nw_runnable)channelWriter)->name,
                         message);
                }
                /*numberOfMessagesSent stats*/
                if (pss.enabled) {
                    channelWriter->scs->numberOfMessagesSent++;
                }
                assert( bytesWritten > 0); /* if permission grantedm the value must be greater 0 */

                }
                
                writtenCountBytesThisBurst += bytesWritten;

#define NW_IS_BUILTIN_DOMAINNAME(name) ((int)(name)[0] == (int)'_')

                /* Do not trace for internal partitions */
                if (bytesWritten>0 && /* might be 0 if access control refuses write permission */
                	!NW_IS_BUILTIN_DOMAINNAME(
                    v_partitionName(v_groupPartition(entry->group)))) {
#undef NW_IS_BUILTIN_DOMAINNAME
                    writtenCountBytes += bytesWritten;
                    writtenCountMessages++;
                    writtenCountMessagesReport++;
                    if (writtenCountMessagesReport == channelWriter->reportInterval) {
                        NW_TRACE_3(Send, 3,
                            "Channel %s: %u messages (%u bytes) "
                            "taken from queue and written to network",
                            ((nw_runnable)channelWriter)->name,
                            writtenCountMessages, writtenCountBytes);
                        writtenCountMessagesReport = 0;
                    }
                    NW_TRACE_3(Send, 4,
                        "Channel %s: data message taken from queue, "
                        "and written to network (partition = %s, topic = %s)",
                        ((nw_runnable)channelWriter)->name,
                        v_partitionName(v_groupPartition(entry->group)),
                        v_topicName(v_groupTopic(entry->group)));
                }
                c_free(message);
                c_free(entry);
            }
            slowingDown = !nw_sendChannelFlush(channelWriter->sendChannel,
                                               TRUE, &credits, &pss);
        } 
    }
    NW_TRACE_3(Send, 2,
               "Channel %s: %u messages (%u bytes) taken from queue and "
               "written to network", ((nw_runnable)channelWriter)->name,
                writtenCountMessages, writtenCountBytes);
}