Skip to content

Use startup packets to set server version - #509

Merged
jesperpedersen merged 1 commit into
pgmoneta:mainfrom
jchrys:paramstatus
Mar 9, 2025
Merged

jesperpedersen merged 1 commit into
pgmoneta:mainfrom
jchrys:paramstatus

Conversation

@jchrys

@jchrys jchrys commented Mar 9, 2025

Copy link
Copy Markdown
Contributor

Utilized Startup packets ('S' B) to set server version. (#498)

@jchrys

jchrys commented Mar 9, 2025

Copy link
Copy Markdown
Contributor Author

Hi, @jesperpedersen
I've implemented the packet('S' B) handling to extract and set server version as discussed.
Could you please review the changes at your convenience?
I appreciate your feedback.

Thanks!

@jesperpedersen

Copy link
Copy Markdown
Member

You need to update doc/manual/advanced/97-acknowledgement.md too

@jesperpedersen
jesperpedersen self-requested a review March 9, 2025 07:42
@jesperpedersen jesperpedersen added the enhancement Improvement to an existing feature label Mar 9, 2025
@jchrys
jchrys force-pushed the paramstatus branch 2 times, most recently from 0f6176b to a394d58 Compare March 9, 2025 07:48
@jchrys

jchrys commented Mar 9, 2025

Copy link
Copy Markdown
Contributor Author

You need to update doc/manual/advanced/97-acknowledgement.md too

I've just updated it :D

Comment thread src/include/security.h Outdated
* @return 0 on success, otherwise 1
*/
int
pgmoneta_extract_server_parameters(struct deque* server_parameters);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should do the deque so struct deque**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULL if 1 is returned

@jchrys jchrys Mar 9, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it. Could you kindly review the updates? :D

Comment thread src/libpgmoneta/server.c Outdated
#include <security.h>
#include <server.h>
#include <utils.h>
#include <deque.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the header includes to be properly sorted.

@jesperpedersen

Copy link
Copy Markdown
Member

./uncrustify.sh too

Comment thread src/libpgmoneta/security.c Outdated
size_t offset;
struct message* msg;
char* name;
char* value;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do

struct deque* sp = NULL;

*server_parameters = NULL;

...

*server_parameters = sp;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I've made the changes

Comment thread src/libpgmoneta/server.c Outdated
while (pgmoneta_deque_iterator_next(iter))
{
pgmoneta_log_debug("%s/process server_parameter '%s'", config->servers[server].name, iter->tag);
if (strcmp("server_version", iter->tag) == 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!strcmp

@jesperpedersen

Copy link
Copy Markdown
Member

You need to reference the main issue in the commit message -- see the git log for examples.

Use git commit --amend

@jchrys

jchrys commented Mar 9, 2025

Copy link
Copy Markdown
Contributor Author

Thanks.
I've just updated it. I appreciate your guidance :D

@jesperpedersen
jesperpedersen merged commit f446b88 into pgmoneta:main Mar 9, 2025
@jesperpedersen

Copy link
Copy Markdown
Member

Merged.

Thanks for your contribution !

@jesperpedersen

Copy link
Copy Markdown
Member

Can you port these changes to pgagroal and pgexporter too ?

@jchrys
jchrys deleted the paramstatus branch March 9, 2025 14:00
@jchrys

jchrys commented Mar 9, 2025

Copy link
Copy Markdown
Contributor Author

Sure. Let me get on it

@jchrys

jchrys commented Mar 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Hello, @jesperpedersen
It looks like pgagroal doesn’t currently use any parameters that could be pulled from the 'S' packet. Could you give me some guidance on how to approach this?

@jesperpedersen

Copy link
Copy Markdown
Member

For now, you just add

struct server
{
 ...
   int port;                        /**< The port of the server */
   int version;                     /**< The major version of the server*/
   int minor_version;               /**< The minor version of the server*/
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants