Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to BSER v2. #270

Closed
wants to merge 10 commits into from
Closed

Conversation

dhruvsinghal
Copy link
Contributor

@dhruvsinghal dhruvsinghal commented Jun 9, 2016

As per https://github.com/facebook/watchman/wiki/Better-Unicode-handling-plan.

  • Added tests specific to BSER v1 (to make sure things don't break during the transition).
  • Renamed STRING to BYTESTRING.
  • Added context type for switching BSER versions.
  • Added BSER version switching logic to server.
  • Added BSER v2 as a capability testable with the version command.
  • Added logic for negotiating up to BSER v2 if both client and server support it.

@ghost
Copy link

ghost commented Jun 9, 2016

@dhruvsinghal updated the pull request.

@@ -48,7 +48,7 @@ static int bser_real(double val, json_dump_callback_t dump, void *data)
return dump((char*)&val, sizeof(val), data);
}

bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed,
bool bunser_bytestring(const char *buf, json_int_t avail, json_int_t *needed,
Copy link
Contributor

Choose a reason for hiding this comment

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

(This should actually be a static function. Feel free to change it to one.)

@sunshowers
Copy link
Contributor

So something to think about is making sure we have the testing story straight for old server/new client and new server/old client. It's probably not something that you'll have to deal with right now but it'll become important very soon.

@ghost
Copy link

ghost commented Jun 9, 2016

@dhruvsinghal updated the pull request.

@facebook-github-bot
Copy link
Contributor

@dhruvsinghal updated the pull request.

@ghost
Copy link

ghost commented Jun 10, 2016

@dhruvsinghal updated the pull request.

@ghost
Copy link

ghost commented Jun 11, 2016

@dhruvsinghal updated the pull request.

1 similar comment
@ghost
Copy link

ghost commented Jun 11, 2016

@dhruvsinghal updated the pull request.

@wez
Copy link
Contributor

wez commented Jun 11, 2016

I took a brief look over this, and it is looking good!

The CI failures appear to be due to unconditionally emitting the new UTF8 string encoding; I think you'll need to add a way to explicitly enable that while defaulting to disabled to make them pass and then I think you're about ready to land this initial series--so long as it doesn't change or break the default behavior it's ok to land partially done work towards the larger goal.

@@ -48,7 +50,8 @@ static int bser_real(double val, json_dump_callback_t dump, void *data)
return dump((char*)&val, sizeof(val), data);
}

bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed,
/* Common codepath for bytestring and UTF-8 encoded strings. */
static bool bunser_string(const char *buf, json_int_t avail, json_int_t *needed,
Copy link
Contributor

Choose a reason for hiding this comment

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

you may want to rename this or change the type signature to help ensure that you got all references to this name and replaced them with bunser_bytestring

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually fine -- in d443952 @dhruvsinghal renamed bunser_string to bunser_bytestring.

@ghost
Copy link

ghost commented Jun 13, 2016

@dhruvsinghal updated the pull request.

@ghost
Copy link

ghost commented Jun 14, 2016

@dhruvsinghal updated the pull request.

@dhruvsinghal
Copy link
Contributor Author

@Sid0 Can you have a look sometime and say if the refactor involving the context variable is on the right track? (Note that this build won't pass the tests yet since ASAN found bugs)

{
json_int_t m_size = 0;
bser_ctx_t measurement_ctx = *ctx;
ctx->dump = measure;
Copy link
Contributor

Choose a reason for hiding this comment

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

measurement_ctx->dump = measure.

@dhruvsinghal dhruvsinghal force-pushed the python3 branch 2 times, most recently from fdbb2c7 to 21ffd60 Compare June 14, 2016 18:29
@ghost
Copy link

ghost commented Jul 22, 2016

@dhruvsinghal updated the pull request.

@ghost
Copy link

ghost commented Jul 25, 2016

@dhruvsinghal updated the pull request.

@ghost
Copy link

ghost commented Aug 15, 2016

@dhruvsinghal updated the pull request.

@@ -353,7 +372,16 @@ int w_bser_dump(const bser_ctx_t* ctx, json_t *json, void *data)
case JSON_INTEGER:
return bser_int(ctx, json_integer_value(json), data);
case JSON_STRING:
return bser_bytestring(ctx, json_string_value(json), data);
wstr = json_to_w_string(json);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this affect BSERv1 as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes. This is a WIP, got pushed prematurely, when I rebased on the latest head and pushed.

@facebook-github-bot
Copy link
Contributor

@dhruvsinghal updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@dhruvsinghal updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@dhruvsinghal updated the pull request - view changes

@ghost
Copy link

ghost commented Aug 18, 2016

@dhruvsinghal updated the pull request - view changes

@ghost
Copy link

ghost commented Aug 18, 2016

@dhruvsinghal updated the pull request - view changes

@@ -401,7 +401,7 @@ int w_bser_write_pdu(const uint32_t bser_version,
}

if (bser_version == 2) {
if (bser_int(&ctx, bser_capabilities, data)) {
if (dump((const char*) &bser_capabilities, 4, data)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make the 4 a #define or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it sizeof(bser_capabilities)

@wez
Copy link
Contributor

wez commented Sep 16, 2016

I'm closing this out because it has been idle for a while and has conflicts. Please open a new pull request rebased off master when you're ready to follow up on this work.

@wez wez closed this Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants