You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2021/01/09 16:03:45 UTC

[GitHub] [incubator-brpc] lorinlee opened a new pull request #1326: bthread/butex: check butex create

lorinlee opened a new pull request #1326:
URL: https://github.com/apache/incubator-brpc/pull/1326


   It seems butex_create should be never failed, but not checked.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on a change in pull request #1326: bthread/butex: check butex create

Posted by GitBox <gi...@apache.org>.
gydong commented on a change in pull request #1326:
URL: https://github.com/apache/incubator-brpc/pull/1326#discussion_r554802130



##########
File path: src/bthread/butex.cpp
##########
@@ -241,10 +241,8 @@ inline int unsleep_if_necessary(ButexBthreadWaiter* w,
 
 void* butex_create() {
     Butex* b = butil::get_object<Butex>();
-    if (b) {
-        return &b->value;
-    }
-    return NULL;
+    CHECK(b != nullptr) << "cannot allocate butex";

Review comment:
       原来的逻辑把决定权交给调用处,应该更灵活一些吧




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] lorinlee commented on a change in pull request #1326: bthread/butex: check butex create

Posted by GitBox <gi...@apache.org>.
lorinlee commented on a change in pull request #1326:
URL: https://github.com/apache/incubator-brpc/pull/1326#discussion_r554901392



##########
File path: src/bthread/butex.cpp
##########
@@ -241,10 +241,8 @@ inline int unsleep_if_necessary(ButexBthreadWaiter* w,
 
 void* butex_create() {
     Butex* b = butil::get_object<Butex>();
-    if (b) {
-        return &b->value;
-    }
-    return NULL;
+    CHECK(b != nullptr) << "cannot allocate butex";

Review comment:
       是在调用处检查一下吗




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on a change in pull request #1326: bthread/butex: check butex create

Posted by GitBox <gi...@apache.org>.
gydong commented on a change in pull request #1326:
URL: https://github.com/apache/incubator-brpc/pull/1326#discussion_r554802130



##########
File path: src/bthread/butex.cpp
##########
@@ -241,10 +241,8 @@ inline int unsleep_if_necessary(ButexBthreadWaiter* w,
 
 void* butex_create() {
     Butex* b = butil::get_object<Butex>();
-    if (b) {
-        return &b->value;
-    }
-    return NULL;
+    CHECK(b != nullptr) << "cannot allocate butex";

Review comment:
       修改的背景是什么?原来的逻辑把决定权交给调用处,应该更灵活一些吧




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] lorinlee commented on a change in pull request #1326: bthread/butex: check butex create

Posted by GitBox <gi...@apache.org>.
lorinlee commented on a change in pull request #1326:
URL: https://github.com/apache/incubator-brpc/pull/1326#discussion_r554896894



##########
File path: src/bthread/butex.cpp
##########
@@ -241,10 +241,8 @@ inline int unsleep_if_necessary(ButexBthreadWaiter* w,
 
 void* butex_create() {
     Butex* b = butil::get_object<Butex>();
-    if (b) {
-        return &b->value;
-    }
-    return NULL;
+    CHECK(b != nullptr) << "cannot allocate butex";

Review comment:
       但是很多调用处都没检查吧




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org