Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187979
b: refs/heads/master
c: d88dca7
h: refs/heads/master
i:
  187977: 3cb2ba6
  187975: 26f8059
v: v3
  • Loading branch information
Neil Horman authored and David S. Miller committed Mar 8, 2010
1 parent 50261ab commit b96e0d2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 38 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f5c445ed4148434f142be0263a8ad7cb58503e8a
refs/heads/master: d88dca79d3852a3623f606f781e013d61486828a
57 changes: 22 additions & 35 deletions trunk/net/tipc/subscr.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,6 @@ struct top_srv {

static struct top_srv topsrv = { 0 };

/**
* htohl - convert value to endianness used by destination
* @in: value to convert
* @swap: non-zero if endianness must be reversed
*
* Returns converted value
*/

static u32 htohl(u32 in, int swap)
{
return swap ? swab32(in) : in;
}

/**
* subscr_send_event - send a message containing a tipc_event to the subscriber
*
Expand All @@ -107,11 +94,11 @@ static void subscr_send_event(struct subscription *sub,
msg_sect.iov_base = (void *)&sub->evt;
msg_sect.iov_len = sizeof(struct tipc_event);

sub->evt.event = htohl(event, sub->swap);
sub->evt.found_lower = htohl(found_lower, sub->swap);
sub->evt.found_upper = htohl(found_upper, sub->swap);
sub->evt.port.ref = htohl(port_ref, sub->swap);
sub->evt.port.node = htohl(node, sub->swap);
sub->evt.event = htonl(event);
sub->evt.found_lower = htonl(found_lower);
sub->evt.found_upper = htonl(found_upper);
sub->evt.port.ref = htonl(port_ref);
sub->evt.port.node = htonl(node);
tipc_send(sub->server_ref, 1, &msg_sect);
}

Expand Down Expand Up @@ -287,16 +274,23 @@ static void subscr_cancel(struct tipc_subscr *s,
{
struct subscription *sub;
struct subscription *sub_temp;
__u32 type, lower, upper;
int found = 0;

/* Find first matching subscription, exit if not found */

type = ntohl(s->seq.type);
lower = ntohl(s->seq.lower);
upper = ntohl(s->seq.upper);

list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list,
subscription_list) {
if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) {
found = 1;
break;
}
if ((type == sub->seq.type) &&
(lower == sub->seq.lower) &&
(upper == sub->seq.upper)) {
found = 1;
break;
}
}
if (!found)
return;
Expand Down Expand Up @@ -325,16 +319,10 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,
struct subscriber *subscriber)
{
struct subscription *sub;
int swap;

/* Determine subscriber's endianness */

swap = !(s->filter & (TIPC_SUB_PORTS | TIPC_SUB_SERVICE));

/* Detect & process a subscription cancellation request */

if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) {
s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
if (ntohl(s->filter) & TIPC_SUB_CANCEL) {
subscr_cancel(s, subscriber);
return NULL;
}
Expand All @@ -359,11 +347,11 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,

/* Initialize subscription object */

sub->seq.type = htohl(s->seq.type, swap);
sub->seq.lower = htohl(s->seq.lower, swap);
sub->seq.upper = htohl(s->seq.upper, swap);
sub->timeout = htohl(s->timeout, swap);
sub->filter = htohl(s->filter, swap);
sub->seq.type = ntohl(s->seq.type);
sub->seq.lower = ntohl(s->seq.lower);
sub->seq.upper = ntohl(s->seq.upper);
sub->timeout = ntohl(s->timeout);
sub->filter = ntohl(s->filter);
if ((!(sub->filter & TIPC_SUB_PORTS) ==
!(sub->filter & TIPC_SUB_SERVICE)) ||
(sub->seq.lower > sub->seq.upper)) {
Expand All @@ -376,7 +364,6 @@ static struct subscription *subscr_subscribe(struct tipc_subscr *s,
INIT_LIST_HEAD(&sub->nameseq_list);
list_add(&sub->subscription_list, &subscriber->subscription_list);
sub->server_ref = subscriber->port_ref;
sub->swap = swap;
memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr));
atomic_inc(&topsrv.subscription_count);
if (sub->timeout != TIPC_WAIT_FOREVER) {
Expand Down
2 changes: 0 additions & 2 deletions trunk/net/tipc/subscr.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ typedef void (*tipc_subscr_event) (struct subscription *sub,
* @nameseq_list: adjacent subscriptions in name sequence's subscription list
* @subscription_list: adjacent subscriptions in subscriber's subscription list
* @server_ref: object reference of server port associated with subscription
* @swap: indicates if subscriber uses opposite endianness in its messages
* @evt: template for events generated by subscription
*/

Expand All @@ -66,7 +65,6 @@ struct subscription {
struct list_head nameseq_list;
struct list_head subscription_list;
u32 server_ref;
int swap;
struct tipc_event evt;
};

Expand Down

0 comments on commit b96e0d2

Please sign in to comment.