[Spread-users] bug in perl binding for spread fixed - now more than 64 groups

M S martin4321234 at googlemail.com
Fri Jul 31 12:00:48 EDT 2009


Because of a typo in the perl interface for spread it was impossible
to receive messages sent to more than 64 groups.

In Spread.xs there is
   newgsize=--ngrps;
instead of
   newgsize=-ngrps;

The Spread C API function SP_receive returns the negative of the
number of groups that the message was sent to. Of course a single
minus operator is needed to calculate the number of groups for the
memory reallocation. Otherwise the memory reallocation would fail.

The patch below fixes this and some minor inaccuracies in Spread.xs.

Would you please upload a fixed Spread package for perl to Cpan
http://search.cpan.org/~jesus/ .
The perl package included in the spread-src-4.1.0 distribution is a
copy of an older version of that.

Kind regards,
Martin

*** Spread-3.17.4.1/Spread.xs.orig	
--- Spread-3.17.4.1/Spread.xs	
***************
*** 54,60 ****
   "Reject: Not Unique",	/* REJECT_NOT_UNIQUE		-6 */
   "Reject: Version",	/* REJECT_VERSION		-7 */
   "Connection Closed",	/* CONNECTION_CLOSED		-8 */
!  ""		,	/*				-9 */
   ""		,	/*				-10 */
   "Illegal Session",	/* ILLEGAL_SESSION		-11 */
   "Illegal Service",	/* ILLEGAL_SERVICE		-12 */
--- 54,60 ----
   "Reject: Not Unique",	/* REJECT_NOT_UNIQUE		-6 */
   "Reject: Version",	/* REJECT_VERSION		-7 */
   "Connection Closed",	/* CONNECTION_CLOSED		-8 */
!  "Reject: Auth",	/* REJECT_AUTH			-9 */
   ""		,	/*				-10 */
   "Illegal Session",	/* ILLEGAL_SESSION		-11 */
   "Illegal Service",	/* ILLEGAL_SERVICE		-12 */
***************
*** 61,73 ****
   "Illegal Message",	/* ILLEGAL_MESSAGE		-13 */
   "Illegal Group",	/* ILLEGAL_GROUP		-14 */
   "Buffer Too Short",	/* BUFFER_TOO_SHORT		-15 */
! #ifdef GROUP_TOO_SHORT
   "Groups Too Short",	/* GROUPS_TOO_SHORT		-16 */
  #endif
  #ifdef MESSAGE_TOO_LONG
   "Message Too Long",	/* MESSAGE_TOO_LONG		-17 */
  #else
! #error You must install spread 3.17.0 client libraries to build perl Spread.
  #endif
   ""};
  static char *connect_params[] = {
--- 61,73 ----
   "Illegal Message",	/* ILLEGAL_MESSAGE		-13 */
   "Illegal Group",	/* ILLEGAL_GROUP		-14 */
   "Buffer Too Short",	/* BUFFER_TOO_SHORT		-15 */
! #ifdef GROUPS_TOO_SHORT
   "Groups Too Short",	/* GROUPS_TOO_SHORT		-16 */
  #endif
  #ifdef MESSAGE_TOO_LONG
   "Message Too Long",	/* MESSAGE_TOO_LONG		-17 */
  #else
! #error You must install spread client libraries to build perl Spread.
  #endif
   ""};
  static char *connect_params[] = {
***************
*** 286,291 ****
--- 286,297 ----
  #else
              goto not_there;
  #endif
+         if (strEQ(name, "REJECT_AUTH"))
+ #ifdef REJECT_AUTH
+             return REJECT_AUTH;
+ #else
+             goto not_there;
+ #endif
          if (strEQ(name, "REJECT_ILLEGAL_NAME"))
  #ifdef REJECT_ILLEGAL_NAME
              return REJECT_ILLEGAL_NAME;
***************
*** 725,731 ****
  		  goto try_again;
  #ifdef GROUPS_TOO_SHORT
  		} else if (ret==GROUPS_TOO_SHORT) {
! 		  newgsize=--ngrps;
  		  ERROR = newSViv(GROUPS_TOO_SHORT);
  		  ngrps = oldgsize;
  		  goto try_again;
--- 731,737 ----
  		  goto try_again;
  #ifdef GROUPS_TOO_SHORT
  		} else if (ret==GROUPS_TOO_SHORT) {
! 		  newgsize=-ngrps;
  		  ERROR = newSViv(GROUPS_TOO_SHORT);
  		  ngrps = oldgsize;
  		  goto try_again;




More information about the Spread-users mailing list