Skip to content

Commit

Permalink
Remove "-f" option in grant and revoke commands
Browse files Browse the repository at this point in the history
The "-f" option in grant and revoke commands had intended to provide
a method to bypass the paxos algorithm hence provide the user a totally
manual way to manage the ticket. However, because the usage of "-f"
often confused the user and also crm_ticket commmand in pacemaker can
provide the same functionality, so remove the "-f" option now.

Signed-off-by: Jiaju Zhang <jjzhang@suse.de>
  • Loading branch information
jjzhang committed Apr 9, 2012
1 parent 1be2b6b commit caeb040
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 41 deletions.
3 changes: 0 additions & 3 deletions src/booth.h
Expand Up @@ -42,13 +42,10 @@
#define BOOTHC_MAGIC 0x5F1BA08C
#define BOOTHC_VERSION 0x00010000

#define BOOTHC_OPT_FORCE 0x00000001

struct boothc_header {
uint32_t magic;
uint32_t version;
uint32_t cmd;
uint32_t option;
uint32_t expiry;
uint32_t len;
uint32_t result;
Expand Down
29 changes: 6 additions & 23 deletions src/main.c
Expand Up @@ -77,7 +77,6 @@ typedef enum {
struct command_line {
int type; /* ACT_ */
int op; /* OP_ */
int force;
char configfile[BOOTH_PATH_LEN];
char lockfile[BOOTH_PATH_LEN];
char site[BOOTH_NAME_LEN];
Expand Down Expand Up @@ -156,7 +155,7 @@ static int do_connect(const char *sock_path)
return fd;
}

static void init_header(struct boothc_header *h, int cmd, int option,
static void init_header(struct boothc_header *h, int cmd,
int result, int data_len)
{
memset(h, 0, sizeof(struct boothc_header));
Expand All @@ -165,7 +164,6 @@ static void init_header(struct boothc_header *h, int cmd, int option,
h->version = BOOTHC_VERSION;
h->len = data_len;
h->cmd = cmd;
h->option = option;
h->result = result;
}

Expand Down Expand Up @@ -346,7 +344,7 @@ void process_connection(int ci)
goto reply;
}
if (local)
h.result = grant_ticket(ticket, h.option);
h.result = grant_ticket(ticket);
else
h.result = BOOTHC_RLT_REMOTE_OP;
break;
Expand All @@ -364,7 +362,7 @@ void process_connection(int ci)
goto reply;
}
if (local)
h.result = revoke_ticket(ticket, h.option);
h.result = revoke_ticket(ticket);
else
h.result = BOOTHC_RLT_REMOTE_OP;
break;
Expand Down Expand Up @@ -527,7 +525,7 @@ static int do_list(void)
int data_len;
int fd, rv;

init_header(&h, BOOTHC_CMD_LIST, 0, 0, 0);
init_header(&h, BOOTHC_CMD_LIST, 0, 0);

fd = do_connect(BOOTHC_SOCK_PATH);
if (fd < 0) {
Expand Down Expand Up @@ -628,7 +626,6 @@ static int do_command(cmd_request_t cmd)
char *buf;
struct boothc_header *h, reply;
int buflen;
uint32_t force = 0;
int fd, rv;
int expire_time;
int i;
Expand All @@ -641,10 +638,7 @@ static int do_command(cmd_request_t cmd)
goto out;
}
h = (struct boothc_header *)buf;
if (cl.force)
force = BOOTHC_OPT_FORCE;
init_header(h, cmd, force, 0,
sizeof(cl.site) + sizeof(cl.ticket));
init_header(h, cmd, 0, sizeof(cl.site) + sizeof(cl.ticket));
strcpy(buf + sizeof(struct boothc_header), cl.site);
strcpy(buf + sizeof(struct boothc_header) + sizeof(cl.site), cl.ticket);

Expand Down Expand Up @@ -854,12 +848,10 @@ static void print_usage(void)
printf(" -D Enable debugging to stderr and don't fork\n");
printf(" -t ticket name\n");
printf(" -s site name\n");
printf(" -f ticket attribute: force, only valid when "
"granting\n");
printf(" -h Print this help, then exit\n");
}

#define OPTION_STRING "c:Dl:t:s:fh"
#define OPTION_STRING "c:Dl:t:s:h"

static char *logging_entity = NULL;

Expand Down Expand Up @@ -970,15 +962,6 @@ static int read_arguments(int argc, char **argv)
}
break;

case 'f':
if (cl.op == OP_GRANT)
cl.force = 1;
else {
print_usage();
exit(EXIT_FAILURE);
}
break;

case 'h':
print_usage();
exit(EXIT_SUCCESS);
Expand Down
15 changes: 2 additions & 13 deletions src/ticket.c
Expand Up @@ -382,17 +382,11 @@ int ticket_recv(void *msg, int msglen)
msglen - sizeof(struct booth_msghdr));
}

int grant_ticket(char *ticket, int force)
int grant_ticket(char *ticket)
{
struct ticket *tk;
int found = 0;

if (force) {
pcmk_handler.store_ticket(ticket, ticket_get_myid(), 0, -1);
pcmk_handler.grant_ticket(ticket);
return BOOTHC_RLT_SYNC_SUCC;
}

list_for_each_entry(tk, &ticket_list, list) {
if (!strcmp(tk->id, ticket)) {
found = 1;
Expand All @@ -412,7 +406,7 @@ int grant_ticket(char *ticket, int force)
}
}

int revoke_ticket(char *ticket, int force)
int revoke_ticket(char *ticket)
{
struct ticket *tk;
int found = 0;
Expand All @@ -428,11 +422,6 @@ int revoke_ticket(char *ticket, int force)
return BOOTHC_RLT_SYNC_FAIL;
}

if (force) {
pcmk_handler.store_ticket(tk->id, -1, 0, 0);
pcmk_handler.revoke_ticket(tk->id);
}

if (tk->owner == -1)
return BOOTHC_RLT_SYNC_SUCC;
else {
Expand Down
4 changes: 2 additions & 2 deletions src/ticket.h
Expand Up @@ -23,8 +23,8 @@

int check_ticket(char *ticket);
int check_site(char *site, int *local);
int grant_ticket(char *ticket, int force);
int revoke_ticket(char *ticket, int force);
int grant_ticket(char *ticket);
int revoke_ticket(char *ticket);
int list_ticket(char **pdata, unsigned int *len);
int catchup_ticket(char **pdata, unsigned int len);
int ticket_recv(void *msg, int msglen);
Expand Down

0 comments on commit caeb040

Please sign in to comment.