[Openais] proposing patches for AMF

Mathieu Marie Mathieu.Marie at Sun.COM
Mon Sep 25 05:40:11 PDT 2006


Hi Hans,

Thanks for your comments, see my answers below.

Hans Feldt wrote:
> Hi,
>
> Some comments:
> - Change name of the macro ALIGN_ADDR(addr) to just ALIGN(x) since =

> that seems more correct the way the macro is used.
ok
>
> - Change testamf1.c to use sched_get_priority_max() instead of =

> hardcoding the limit and using #ifdefs which is ugly.
I agree. I modified it as you proposed.
Failure to retrieve the priority max is non fatal, but the scheduling =

will not be set.
>
> - Parenthesis around return values is style, don't change that, should =

> be consistent with rest of the file since no design rule exist about =

> that.
Ok, I reverted it back to how it was.
>
> I have no problem merging these fixes after that. Can you send the new =

> diff file as an attachment instead?
The diffs are in attachment.
>
> However I don't understand how it can work on sparc even with these =

> change since the totem interface delivers messages to AMF totally =

> unaligned:
>
>> Sep 25  9:37:28.547505 [amf.c:1703] =

>> >message_handler_req_exec_amf_sync_data: rec 568 bytes, type 2, ptr =

>> 0x4036a026
>> Sep 25  9:37:28.547535 [amf.c:1703] =

>> >message_handler_req_exec_amf_sync_data: rec 584 bytes, type 3, ptr =

>> 0x4036a263
>> Sep 25  9:37:28.547571 [amf.c:1703] =

>> >message_handler_req_exec_amf_sync_data: rec 584 bytes, type 3, ptr =

>> 0x4036a011
The serialize/deserialize methods I modified will end up being called by =

the method message_handler_req_exec_amf_sync_data() you 're referring to.

example of stack :

amf_deserialize_SaUint32T
amf_application_deserialize
message_handler_req_exec_amf_sync_data
...

With my changes the amf messages that are sent/retrieved are being aligned.
By browsing the other services, I realized that all the other messages =

seem to be aligned in openAIS using "__attribute__((aligned(8)))" when =

declaring datastructures that are exchanged by Totem.
The amf could follow the same policy too.

> Can sparcs read words at unaligned addresses?
No, this is not possible, the sparc physical hardware cannot read and =

write unaligned data. It could be done by using the "-misalign" =

compilation flag, but it would dramatically slow down *every* memory =

accesses.

Regards,
Mathieu

>
> Regards,
> Hans
>
>
> Mathieu Marie wrote:
>> Hi,
>>
>> This is my first time on this alias.
>>
>> I just installed openAIS (trunk) on Solaris and tried to play around =

>> with AMF.
>> I found and fixed some minor problems that are mentioned below,
>> I added my diffs, in case you're interested in incorporating them.
>>
>>
>> Here are the problems I found :
>>
>> 1- On Solaris/sparc, the amf crashes with a SIGBUS, because
>>      the serialize/deserialize methods are not aligned for sparc.
>>      (amfutil.c)
>>      I fixed it by aligning everything on 8 on sparc. The current fix
>>      does not allow to communicate between sparc and non-sparc
>>      nodes, because I differentiated the sparc case.
>>      To allow them to communicate, the ALIGN_ADDR macro below
>>      should be the same in sparc and non-sparc cases.
>>
>>      In the same fix, I modified the sa_serialize_SaUint64T to make
>>      it similar to the other methods (that method is not currently =

>> used in trunk).
>>
>> Index: amfutil.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- amfutil.c   (revision 1241)
>> +++ amfutil.c   (working copy)
>> @@ -1067,14 +1067,19 @@
>>         return assignment_state_text[state];
>>  }
>>  =

>> -#define ALIGN_ADDR(addr) ((addr) + (4 - ((unsigned long)(addr) % 4)))
>> +#ifdef __sparc
>> +#define ALIGN_ADDR(addr) ((addr) + (8 - ((unsigned long)(addr) % 8)))
>> +#else
>> +#define ALIGN_ADDR(addr) addr
>> +#endif
>>  =

>>  char *amf_serialize_SaNameT (char *buf, int *size, int *offset, =

>> SaNameT *name)
>>  {
>>         char *tmp =3D buf;
>>  =

>> -       if ((*size - *offset ) < sizeof (SaNameT)) {
>> -               *size +=3D sizeof (SaNameT);
>> +       if ((*size - *offset ) < ALIGN_ADDR(sizeof (SaNameT))) {
>> +               *size +=3D ALIGN_ADDR(sizeof(SaNameT));
>> +
>>                 tmp =3D realloc (buf, *size);
>>                 if (tmp =3D=3D NULL) {
>>                         openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
>> @@ -1083,7 +1088,7 @@
>>  =

>>         memcpy (&tmp[*offset], name, sizeof (SaNameT));
>>  =

>> -       (*offset) +=3D sizeof (SaNameT);
>> +       (*offset) +=3D ALIGN_ADDR(sizeof (SaNameT));
>>  =

>>         return tmp;
>>  }
>> @@ -1098,61 +1103,77 @@
>>                 len =3D 0;
>>         }
>>  =

>> -       return amf_serialize_opaque (buf, size, offset, str, len);
>> +       return (amf_serialize_opaque (buf, size, offset, str, len));
>>  }
>>  =

>>  char *amf_serialize_SaUint32T (char *buf, int *size, int *offset, =

>> SaUint32T num)
>>  {
>>         char *tmp =3D buf;
>> +       int lsize =3D *size;
>>  =

>> -       if ((*size - *offset ) < sizeof (SaUint32T)) {
>> -               *size +=3D sizeof (SaUint32T);
>> -               tmp =3D realloc (buf, *size);
>> +       if ((*size - *offset ) < ALIGN_ADDR(sizeof (SaUint32T))) {
>> +               lsize +=3D ALIGN_ADDR(sizeof (SaUint32T));
>> +               tmp =3D realloc (buf, lsize);
>>                 if (tmp =3D=3D NULL) {
>>                         openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
>>                 }
>>         }
>>  =

>>         *((SaUint32T *)&tmp[*offset]) =3D num;
>> -       (*offset) +=3D sizeof (SaUint32T);
>> +       (*offset) +=3D ALIGN_ADDR(sizeof (SaUint32T));
>> +       *size =3D lsize;
>>  =

>> -       return tmp;
>> +       return (tmp);
>>  }
>>  =

>> -char *amf_serialize_SaUint64T (char *buf, SaUint64T num)
>> +char *amf_serialize_SaUint64T (char *buf, int *size, int *offset, =

>> SaUint64T num)
>>  {
>> -       *((SaUint64T *)buf) =3D num;
>> -       return buf + sizeof (SaUint64T);
>> +       char *tmp =3D buf;
>> +       int lsize =3D *size;
>> +
>> +       if ((*size - *offset ) < ALIGN_ADDR(sizeof (SaUint64T))) {
>> +               lsize +=3D ALIGN_ADDR(sizeof (SaUint64T));
>> +               tmp =3D realloc (buf, lsize);
>> +               if (tmp =3D=3D NULL) {
>> +                       openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
>> +               }
>> +       }
>> +
>> +       *((SaUint64T *)&tmp[*offset]) =3D num;
>> +       (*offset) +=3D ALIGN_ADDR(sizeof (SaUint64T));
>> +       *size =3D lsize;
>> +
>> +       return (tmp);
>>  }
>>  =

>>  char *amf_serialize_opaque (
>>         char *buf, int *size, int *offset, char *src, int cnt)
>>  {
>> -       unsigned int required_size;
>> +
>>         char *tmp =3D buf;
>> +       int lsize =3D *size;
>>  =

>> -       required_size =3D cnt + sizeof (SaUint32T);
>> -
>> -       if ((*size - *offset ) < required_size) {
>> -               *size +=3D required_size;
>> -               tmp =3D realloc (buf, *size);
>> +       if ((*size - *offset ) < (ALIGN_ADDR(sizeof(SaUint32T)) + =

>> ALIGN_ADDR(cnt))) {
>> +               lsize +=3D (ALIGN_ADDR(sizeof(SaUint32T)) + =

>> ALIGN_ADDR(cnt));
>> +               tmp =3D realloc (buf, lsize);
>>                 if (tmp =3D=3D NULL) {
>>                         openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
>>                 }
>>         }
>>  =

>>         *((SaUint32T *)&tmp[*offset]) =3D cnt;
>> -       (*offset) +=3D sizeof (SaUint32T);
>> +       (*offset) +=3D ALIGN_ADDR(sizeof (SaUint32T));
>>         memcpy (&tmp[*offset], src, cnt);
>> -       (*offset) +=3D cnt;
>> +       (*offset) +=3D ALIGN_ADDR(cnt);
>> +       *size =3D lsize;
>>  =

>> -       return tmp;
>> +       return (tmp);
>>  }
>>  =

>>  char *amf_deserialize_SaNameT (char *buf, SaNameT *name)
>>  {
>>         memcpy (name, buf, sizeof (SaNameT));
>> -       return (buf + sizeof (SaNameT));
>> +       return (buf + ALIGN_ADDR(sizeof (SaNameT)));
>>  }
>>  =

>>  char *amf_deserialize_SaStringT (char *buf, SaStringT *str)
>> @@ -1161,7 +1182,7 @@
>>         char *tmp, *tmp_str;
>>  =

>>         len =3D *((SaUint32T *)buf);
>> -       tmp =3D buf + sizeof (SaUint32T);
>> +       tmp =3D buf + ALIGN_ADDR(sizeof (SaUint32T));
>>  =

>>         if (len > 0) {
>>                 tmp_str =3D amf_malloc (len + 1);
>> @@ -1172,28 +1193,28 @@
>>                 *str =3D NULL;
>>         }
>>  =

>> -       tmp +=3D len;
>> +       tmp +=3D ALIGN_ADDR(len);
>>  =

>> -       return tmp;
>> +       return (tmp);
>>  }
>>  =

>>  char *amf_deserialize_SaUint32T (char *buf, SaUint32T *num)
>>  {
>>         *num =3D *((SaUint32T *)buf);
>> -       return buf + sizeof (SaUint32T);
>> +       return (buf + ALIGN_ADDR(sizeof (SaUint32T)));
>>  }
>>  =

>>  char *amf_deserialize_SaUint64T (char *buf, SaUint64T *num)
>>  {
>>         *num =3D *((SaUint64T *)buf);
>> -       return buf + sizeof (SaUint64T);
>> +       return (buf + ALIGN_ADDR(sizeof (SaUint64T)));
>>  }
>>  =

>>  char *amf_deserialize_opaque (char *buf, char *dst, int *cnt)
>>  {
>>         *cnt =3D *((SaUint32T *)buf);
>> -       memcpy (dst, buf + sizeof (SaUint32T), *cnt);
>> -       return buf + *cnt + sizeof (SaUint32T);
>> +       memcpy (dst, buf + ALIGN_ADDR(sizeof (SaUint32T)), *cnt);
>> +       return (buf + (ALIGN_ADDR(sizeof (SaUint32T)) + =

>> ALIGN_ADDR(*cnt)));
>>  }
>>  =

>>  void *_amf_malloc (size_t size, char *file, unsigned int line)
>>
>> Index: amf.h
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- amf.h       (revision 1241)
>> +++ amf.h       (working copy)
>> @@ -542,7 +542,8 @@
>>         char *buf, int *size, int *offset, SaStringT str);
>>  extern char *amf_serialize_SaUint32T (
>>         char *buf, int *size, int *offset, SaUint32T num);
>> -extern char *amf_serialize_SaUint64T (char *buf, SaUint64T num);
>> +extern char *amf_serialize_SaUint64T (
>> +        char *buf, int *size, int *offset, SaUint64T num);
>>  extern char *amf_serialize_opaque (
>>         char *buf, int *size, int *offset, char *cp, int cnt);
>>  extern char *amf_deserialize_SaNameT (char *buf, SaNameT *name);
>>
>>
>>
>> 2- On Solaris, the SA components executed have no names.
>>
>> "ps -p <pid> -o comm" will show that the process has no command name.
>>
>>      This is due to the way the execve() is called in =

>> openais-instantiate.c.
>>      On linux, the command name of a component is shown between
>>      square brackets, due to that same problem.
>>
>>
>> Index: openais-instantiate.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- openais-instantiate.c       (revision 1241)
>> +++ openais-instantiate.c       (working copy)
>> @@ -96,7 +96,7 @@
>>                 /*
>>                  * child process
>>                  */
>> -               res =3D execve (argv[1], &argv[2], envp);
>> +               res =3D execve (argv[1], &argv[1], envp);
>>                 if (res =3D=3D -1) {
>>                         return (errno);
>>                 }
>>
>>
>> 3- When killing the testamf1 component, it makes the aisexec process =

>> crash on both of my nodes.
>>      This comes from an "=3D=3D" sign in the clc_cli_script file, instea=
d =

>> of an "-eg".
>>      (Even with this fix, every times clc_cli_script returns a =

>> non-zero value,
>>      the aisexec process will crash. I've seen TODOs in that portion =

>> of the code, so I stopped there).
>>
>> Index: clc_cli_script
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- clc_cli_script      (revision 1240)
>> +++ clc_cli_script      (working copy)
>> @@ -60,7 +60,7 @@
>>  #      `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
>>         kill -9 `cat =

>> $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
>>         STATUS=3D$?
>> -       if [ $STATUS =3D=3D 1 ]; then
>> +       if [ $STATUS -eq 1 ]; then
>>                 exit 0
>>         else
>>                 exit $STATUS
>>
>>
>> 4- the testamf1 component also prints out a trace that it can't set the
>>      scheduling class to RR with a priority of 99, because the max =

>> priority
>>      for RR on solaris is 59.
>>
>> Index: testamf1.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> --- testamf1.c  (revision 1240)
>> +++ testamf1.c  (working copy)
>> @@ -299,11 +299,17 @@
>>  =

>>  SaVersionT version =3D { 'B', 1, 1 };
>>  =

>> -#if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || =

>> defined(OPENAIS_LINUX) || defined(OPENAIS_SOLARIS))
>> +#if ! defined(TS_CLASS)
>> +#if (defined(OPENAIS_BSD) || defined(OPENAIS_LINUX))
>>  static struct sched_param sched_param =3D {
>>      sched_priority: 99
>>  };
>> +#elif defined(OPENAIS_SOLARIS)
>> +static struct sched_param sched_param =3D {
>> +    sched_priority: 59
>> +    };
>>  #endif
>> +#endif
>>  =

>>  void sigintr_handler (int signum) {
>>         stop =3D FINALIZE;
>> @@ -379,7 +385,7 @@
>>  #if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || =

>> defined(OPENAIS_LINUX) || defined(OPENAIS_SOLARIS))
>>         result =3D sched_setscheduler (0, SCHED_RR, &sched_param);
>>         if (result =3D=3D -1) {
>> -               fprintf (stderr, "%d: couldn't set sched priority\n", =

>> (int)getpid());
>> +               fprintf (stderr, "%d: couldn't set sched priority =

>> (%s)\n", (int)getpid(), strerror(errno));
>>         }
>>  #endif
>>
>>
>> Mathieu
>> _______________________________________________
>> Openais mailing list
>> Openais at lists.osdl.org
>> https://lists.osdl.org/mailman/listinfo/openais
>>
>

-------------- next part --------------
Index: exec/amf.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- exec/amf.h	(revision 1244)
+++ exec/amf.h	(working copy)
@@ -542,7 +542,8 @@
 	char *buf, int *size, int *offset, SaStringT str);
 extern char *amf_serialize_SaUint32T (
 	char *buf, int *size, int *offset, SaUint32T num);
-extern char *amf_serialize_SaUint64T (char *buf, SaUint64T num);
+extern char *amf_serialize_SaUint64T (
+        char *buf, int *size, int *offset, SaUint64T num);
 extern char *amf_serialize_opaque (
 	char *buf, int *size, int *offset, char *cp, int cnt);
 extern char *amf_deserialize_SaNameT (char *buf, SaNameT *name);
Index: exec/amfutil.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- exec/amfutil.c	(revision 1244)
+++ exec/amfutil.c	(working copy)
@@ -1067,14 +1067,19 @@
 	return assignment_state_text[state];
 }

-#define ALIGN_ADDR(addr) ((addr) + (4 - ((unsigned long)(addr) % 4)))
+#ifdef __sparc
+#define ALIGN(x) ((x) + (8 - ((unsigned long)(x) % 8)))
+#else
+#define ALIGN(x) x
+#endif

 char *amf_serialize_SaNameT (char *buf, int *size, int *offset, SaNameT *n=
ame)
 {
 	char *tmp =3D buf;

-	if ((*size - *offset ) < sizeof (SaNameT)) {
-		*size +=3D sizeof (SaNameT);
+	if ((*size - *offset ) < ALIGN(sizeof (SaNameT))) {
+		*size +=3D ALIGN(sizeof(SaNameT));
+
 		tmp =3D realloc (buf, *size);
 		if (tmp =3D=3D NULL) {
 			openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
@@ -1083,0 +1088,0 @@

 	memcpy (&tmp[*offset], name, sizeof (SaNameT));

-	(*offset) +=3D sizeof (SaNameT);
+	(*offset) +=3D ALIGN(sizeof (SaNameT));

 	return tmp;
 }
@@ -1104,3 +1109,4 @@
 char *amf_serialize_SaUint32T (char *buf, int *size, int *offset, SaUint32=
T num)
 {
 	char *tmp =3D buf;
+	int lsize =3D *size;

-	if ((*size - *offset ) < sizeof (SaUint32T)) {
-		*size +=3D sizeof (SaUint32T);
-		tmp =3D realloc (buf, *size);
+	if ((*size - *offset ) < ALIGN(sizeof (SaUint32T))) {
+		lsize +=3D ALIGN(sizeof (SaUint32T));
+		tmp =3D realloc (buf, lsize);
 		if (tmp =3D=3D NULL) {
 			openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
 		}
 	}

 	*((SaUint32T *)&tmp[*offset]) =3D num;
-	(*offset) +=3D sizeof (SaUint32T);
+	(*offset) +=3D ALIGN(sizeof (SaUint32T));
+	*size =3D lsize;

 	return tmp;
 }

-char *amf_serialize_SaUint64T (char *buf, SaUint64T num)
+char *amf_serialize_SaUint64T (char *buf, int *size, int *offset, SaUint64=
T num)
 {
-	*((SaUint64T *)buf) =3D num;
-	return buf + sizeof (SaUint64T);
+	char *tmp =3D buf;
+	int lsize =3D *size;
+
+	if ((*size - *offset ) < ALIGN(sizeof (SaUint64T))) {
+		lsize +=3D ALIGN(sizeof (SaUint64T));
+		tmp =3D realloc (buf, lsize);
+		if (tmp =3D=3D NULL) {
+			openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
+		}
+	}
+
+	*((SaUint64T *)&tmp[*offset]) =3D num;
+	(*offset) +=3D ALIGN(sizeof (SaUint64T));
+	*size =3D lsize;
+
+	return tmp;
 }

 char *amf_serialize_opaque (
 	char *buf, int *size, int *offset, char *src, int cnt)
 {
-	unsigned int required_size;
+
 	char *tmp =3D buf;
+	int lsize =3D *size;

-	required_size =3D cnt + sizeof (SaUint32T);
-
-	if ((*size - *offset ) < required_size) {
-		*size +=3D required_size;
-		tmp =3D realloc (buf, *size);
+	if ((*size - *offset ) < (ALIGN(sizeof(SaUint32T)) + ALIGN(cnt))) {
+		lsize +=3D (ALIGN(sizeof(SaUint32T)) + ALIGN(cnt));
+		tmp =3D realloc (buf, lsize);
 		if (tmp =3D=3D NULL) {
 			openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
 		}
 	}

 	*((SaUint32T *)&tmp[*offset]) =3D cnt;
-	(*offset) +=3D sizeof (SaUint32T);
+	(*offset) +=3D ALIGN(sizeof (SaUint32T));
 	memcpy (&tmp[*offset], src, cnt);
-	(*offset) +=3D cnt;
+	(*offset) +=3D ALIGN(cnt);
+	*size =3D lsize;

 	return tmp;
 }
@@ -1152,5 +1173,5 @@
 char *amf_deserialize_SaNameT (char *buf, SaNameT *name)
 {
 	memcpy (name, buf, sizeof (SaNameT));
-	return (buf + sizeof (SaNameT));
+	return (buf + ALIGN(sizeof (SaNameT)));
 }

 char *amf_deserialize_SaStringT (char *buf, SaStringT *str)
@@ -1161,1 +1182,1 @@
 	char *tmp, *tmp_str;

 	len =3D *((SaUint32T *)buf);
-	tmp =3D buf + sizeof (SaUint32T);
+	tmp =3D buf + ALIGN(sizeof (SaUint32T));

 	if (len > 0) {
 		tmp_str =3D amf_malloc (len + 1);
@@ -1172,2 +1193,2 @@
 		*str =3D NULL;
 	}

-	tmp +=3D len;
+	tmp +=3D ALIGN(len);

 	return tmp;
 }
@@ -1180,5 +1201,5 @@
 char *amf_deserialize_SaUint32T (char *buf, SaUint32T *num)
 {
 	*num =3D *((SaUint32T *)buf);
-	return buf + sizeof (SaUint32T);
+	return buf + ALIGN(sizeof (SaUint32T));
 }

 char *amf_deserialize_SaUint64T (char *buf, SaUint64T *num)
 {
 	*num =3D *((SaUint64T *)buf);
-	return buf + sizeof (SaUint64T);
+	return buf + ALIGN(sizeof (SaUint64T));
 }

 char *amf_deserialize_opaque (char *buf, char *dst, int *cnt)
 {
 	*cnt =3D *((SaUint32T *)buf);
-	memcpy (dst, buf + sizeof (SaUint32T), *cnt);
-	return buf + *cnt + sizeof (SaUint32T);
+	memcpy (dst, buf + ALIGN(sizeof (SaUint32T)), *cnt);
+	return buf + ALIGN(sizeof (SaUint32T)) + ALIGN(*cnt);
 }

 void *_amf_malloc (size_t size, char *file, unsigned int line)
-------------- next part --------------
Index: test/clc_cli_script
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- test/clc_cli_script	(revision 1244)
+++ test/clc_cli_script	(working copy)
@@ -60,7 +60,7 @@
 #	`cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	kill -9 `cat $PIDFILEPATH/openais_cleanup_$SA_AMF_COMPONENT_NAME`
 	STATUS=3D$?
-	if [ $STATUS =3D=3D 1 ]; then
+	if [ $STATUS -eq 1 ]; then
 		exit 0
 	else
 		exit $STATUS
-------------- next part --------------
Index: exec/openais-instantiate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- exec/openais-instantiate.c	(revision 1244)
+++ exec/openais-instantiate.c	(working copy)
@@ -96,7 +96,7 @@
 		/*
 		 * child process
 		 */
-		res =3D execve (argv[1], &argv[2], envp);
+		res =3D execve (argv[1], &argv[1], envp);
 		if (res =3D=3D -1) {
 			return (errno);
 		}
-------------- next part --------------
Index: test/testamf1.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- test/testamf1.c	(revision 1244)
+++ test/testamf1.c	(working copy)
@@ -298,11 +298,8 @@
 SaAmfCallbacksT amfCallbacks;
 =

 SaVersionT version =3D { 'B', 1, 1 };
-
 #if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || defined(OPENAIS_LINUX)=
 || defined(OPENAIS_SOLARIS))
-static struct sched_param sched_param =3D {
-    sched_priority: 99
-};
+static struct sched_param sched_param;
 #endif
 =

 void sigintr_handler (int signum) {
@@ -377,10 +374,19 @@
 	signal (SIGUSR2, sigusr2_handler);
 =

 #if ! defined(TS_CLASS) && (defined(OPENAIS_BSD) || defined(OPENAIS_LINUX)=
 || defined(OPENAIS_SOLARIS))
-	result =3D sched_setscheduler (0, SCHED_RR, &sched_param);
-	if (result =3D=3D -1) {
-		fprintf (stderr, "%d: couldn't set sched priority\n", (int)getpid());
- 	}
+
+	sched_param.sched_priority =3D sched_get_priority_max(SCHED_RR);
+	if (sched_param.sched_priority =3D=3D -1) {
+		fprintf (stderr, "%d: couldn't retrieve the maximum scheduling " \
+		    "priority supported by the Round-Robin class (%s)\n",
+		    (int)getpid(), strerror(errno));
+	} else {
+		result =3D sched_setscheduler (0, SCHED_RR, &sched_param);
+		if (result =3D=3D -1) {
+			fprintf (stderr, "%d: couldn't set sched priority (%s)\n",
+			    (int)getpid(), strerror(errno));
+		}
+	}
 #endif
 =

 	do {


More information about the Openais mailing list