Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbf21c9

Browse files
committed
Add an assert checking if raftable has been configured.
1 parent10ca191 commitfbf21c9

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

‎contrib/raftable/raftable.c‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ static int get_connection(void)
153153

154154
char*raftable_get(constchar*key,size_t*len)
155155
{
156+
Assert(wcfg.id >=0);
156157
returnstate_get(shared.state,key,len);
157158
}
158159

@@ -249,6 +250,8 @@ bool raftable_set(const char *key, const char *value, size_t vallen, int timeout
249250
TimestampTznow;
250251
intelapsed_ms;
251252

253+
Assert(wcfg.id >=0);
254+
252255
keylen=strlen(key)+1;
253256

254257
size+=sizeof(RaftableField)-1;
@@ -308,6 +311,7 @@ void raftable_every(void (*func)(const char *, const char *, size_t, void *), vo
308311
char*key,*value;
309312
size_tlen;
310313
Assert(shared.state);
314+
Assert(wcfg.id >=0);
311315

312316
scan=state_scan(shared.state);
313317
while (state_next(shared.state,scan,&key,&value,&len))
@@ -327,6 +331,7 @@ raftable_sql_list(PG_FUNCTION_ARGS)
327331
MemoryContextoldcontext;
328332

329333
Assert(shared.state);
334+
Assert(wcfg.id >=0);
330335

331336
if (SRF_IS_FIRSTCALL())
332337
{
@@ -399,8 +404,8 @@ _PG_init(void)
399404

400405
DefineCustomIntVariable("raftable.id",
401406
"Raft peer id of current instance",NULL,
402-
&wcfg.id,0,
403-
0,RAFTABLE_PEERS_MAX-1,
407+
&wcfg.id,-1,
408+
-1,RAFTABLE_PEERS_MAX-1,
404409
PGC_POSTMASTER,0,NULL,NULL,NULL
405410
);
406411

@@ -452,13 +457,18 @@ _PG_init(void)
452457
&peerstr,"0:127.0.0.1:6543",
453458
PGC_POSTMASTER,0,NULL,NULL,NULL
454459
);
455-
parse_peers(wcfg.peers,peerstr);
456-
457-
request_shmem();
458-
worker_register(&wcfg);
459460

460461
PreviousShmemStartupHook=shmem_startup_hook;
461-
shmem_startup_hook=startup_shmem;
462+
463+
if (wcfg.id >=0)
464+
{
465+
parse_peers(wcfg.peers,peerstr);
466+
467+
request_shmem();
468+
worker_register(&wcfg);
469+
470+
shmem_startup_hook=startup_shmem;
471+
}
462472
}
463473

464474
void

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp