CVS update: php3/functions
| From: | steinm | Date: | Wed, 02 Jun 1999 10:06:42 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6457@lists.php.net to get a copy of this message | ||
Date: Wednesday June 2, 1999 @ 6:06
Author: steinm
Update of /repository/php3/functions
In directory php:/tmp/cvs-serv21084/functions
Modified Files:
hg_comm.c hg_comm.h hw.c
Log Message:
- hw_modifyobject() does proper object locking
Index: php3/functions/hg_comm.c
diff -u php3/functions/hg_comm.c:1.20 php3/functions/hg_comm.c:1.21
--- php3/functions/hg_comm.c:1.20 Tue May 11 13:00:50 1999
+++ php3/functions/hg_comm.c Wed Jun 2 06:06:42 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hg_comm.c,v 1.20 1999/05/11 17:00:50 steinm Exp $ */
+/* $Id: hg_comm.c,v 1.21 1999/06/02 10:06:42 steinm Exp $ */
/* #define HW_DEBUG */
@@ -1393,13 +1393,14 @@
int send_groupchangeobject(int sockfd, hw_objectID objectID, char *modification)
{
hw_objectID *childIDs;
- int count, i;
+ int count, i, error;
- if(0 > send_changeobject(sockfd, objectID, modification)) /* {
- fprintf(stderr, "Cannot change 0x%X\n", objectID);
- } else
- fprintf(stderr, "Changed 0x%X\n", objectID);
-*/
+ if(0 == (error = send_lock(sockfd, objectID))) {
+ send_changeobject(sockfd, objectID, modification);
+ send_unlock(sockfd, objectID);
+ }/* else
+ fprintf(stderr, "Could not lock 0x%X (error = %d)\n", objectID, error); */
+
if(0 == send_children(sockfd, objectID, &childIDs, &count)) {
/* fprintf(stderr, "Changing Children of 0x%X\n", objectID); */
for(i=0; i<count; i++)
@@ -1407,8 +1408,8 @@
/* fprintf(stderr, "Cannot change 0x%X\n", objectID) */;
if(childIDs)
efree(childIDs);
- } /* else
- fprintf(stderr, "No Children of 0x%X\n", objectID); */
+ }/* else
+ fprintf(stderr, "No Children of 0x%X\n", objectID); */
return(0);
}
@@ -1511,6 +1512,41 @@
return error;
}
+int send_lock(int sockfd, hw_objectID objectID)
+{
+ hg_msg msg, *retmsg;
+ int length, error;
+ char *tmp;
+
+ length = HEADER_LENGTH + sizeof(hw_objectID);
+
+ build_msg_header(&msg, length, msgid++, GETANDLOCK_MESSAGE);
+
+ if ( (msg.buf = (char *)emalloc(length-HEADER_LENGTH)) == NULL ) {
+ lowerror = LE_MALLOC;
+ return(-1);
+ }
+
+ tmp = build_msg_int(msg.buf, objectID);
+
+ if ( send_hg_msg(sockfd, &msg, length) == -1 ) {
+ efree(msg.buf);
+ return(-1);
+ }
+
+ efree(msg.buf);
+ retmsg = recv_hg_msg(sockfd);
+ if ( retmsg == NULL ) {
+ return(-1);
+ }
+
+ error = (int) *(retmsg->buf);
+
+ efree(retmsg->buf);
+ efree(retmsg);
+ return error;
+}
+
int send_insertobject(int sockfd, char *objrec, char *parms, hw_objectID *objectID)
{
hg_msg msg, *retmsg;
@@ -1558,7 +1594,7 @@
int send_unlock(int sockfd, hw_objectID objectID)
{
- hg_msg msg, *retmsg;
+ hg_msg msg;
int length, error;
char *tmp;
@@ -1580,16 +1616,7 @@
}
efree(msg.buf);
- retmsg = recv_hg_msg(sockfd);
- if ( retmsg == NULL ) {
- return(-1);
- }
-
- error = (int) *(retmsg->buf);
-
- efree(retmsg->buf);
- efree(retmsg);
- return error;
+ return 0;
}
int send_incollections(int sockfd, int retcol, int cobjids, hw_objectID *objectIDs, int ccollids,
hw_objectID *collIDs, int *count, hw_objectID **retIDs)
Index: php3/functions/hg_comm.h
diff -u php3/functions/hg_comm.h:1.6 php3/functions/hg_comm.h:1.7
--- php3/functions/hg_comm.h:1.6 Fri Apr 30 06:29:17 1999
+++ php3/functions/hg_comm.h Wed Jun 2 06:06:42 1999
@@ -23,7 +23,7 @@
*/
-/* $Id: hg_comm.h,v 1.6 1999/04/30 10:29:17 steinm Exp $ */
+/* $Id: hg_comm.h,v 1.7 1999/06/02 10:06:42 steinm Exp $ */
#ifndef _HG_COMM_H
#define _HG_COMM_H
@@ -163,6 +163,7 @@
extern int send_groupchangeobject(int sockfd, hw_objectID objectID, char *mod);
extern int send_getobject(int sockfd, hw_objectID objectID, char **attributes);
extern int send_getandlock(int sockfd, hw_objectID objectID, char **attributes);
+extern int send_lock(int sockfd, hw_objectID objectID);
extern int send_unlock(int sockfd, hw_objectID objectID);
extern int send_gettext(int sockfd, hw_objectID objectID, int mode, int rootid, char **objattr,
char **bodytag, char **text, int *count);
extern int send_edittext(int sockfd, char *objattr, char *text);
Index: php3/functions/hw.c
diff -u php3/functions/hw.c:1.36 php3/functions/hw.c:1.37
--- php3/functions/hw.c:1.36 Tue Jun 1 10:25:21 1999
+++ php3/functions/hw.c Wed Jun 2 06:06:42 1999
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.36 1999/06/01 14:25:21 steinm Exp $ */
+/* $Id: hw.c,v 1.37 1999/06/02 10:06:42 steinm Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -1549,9 +1549,21 @@
/* fprintf(stderr, "modifyobject: %s\n", modification); */
switch(mode) {
case 0:
- if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
- RETURN_FALSE;
- free(modification);
+ if (0 != (ptr->lasterror = send_lock(ptr->socket, id))) {
+ if (0 != (ptr->lasterror = send_changeobject(ptr->socket, id, modification))) {
+ if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
+ php3_error(E_WARNING,"Aiii, Changeobject failed and couldn't unlock object (id =
0x%X)", id);
+ free(modification);
+ RETURN_FALSE;
+ }
+ free(modification);
+ RETURN_FALSE;
+ }
+ if (0 != (ptr->lasterror = send_unlock(ptr->socket, id))) {
+ php3_error(E_WARNING,"Aiii, Changed object but couldn't unlock object (id =
0x%X)", id);
+ free(modification);
+ RETURN_FALSE;
+ }
}
break;
case 1:
@@ -1560,11 +1572,11 @@
modify objects which cannot be modified e.g. because an attribute cannot
be removed. In such a case no further modification on that object is done.
Doing a 'rem Rights\add Rights=R:a' will fail completely if the attribute
- Rights is not there already.
+ Rights is not there already. The object locking is done in send_groupchangeobject();
*/
if (0 != (ptr->lasterror = send_groupchangeobject(ptr->socket, id, modification))) {
- RETURN_FALSE;
free(modification);
+ RETURN_FALSE;
}
break;
default: