Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
e1f29f7c
Kaydet (Commit)
e1f29f7c
authored
Eyl 27, 2005
tarafından
Gürer Özen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
comar içi hatalar FAIL değil ERROR döndürsün
ipc/rpc düzenlemeleri dahası gelecek...
üst
8c488c16
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
117 additions
and
59 deletions
+117
-59
comar.py
comard/bindings/comar.py
+16
-15
libcomar.h
comard/bindings/libcomar.h
+14
-12
ipc.h
comard/include/ipc.h
+4
-2
model.xml
comard/model.xml
+3
-2
csl.c
comard/src/csl.c
+16
-0
job.c
comard/src/job.c
+11
-4
main.c
comard/src/main.c
+3
-0
rpc_unix.c
comard/src/rpc_unix.c
+50
-24
No files found.
comard/bindings/comar.py
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -24,18 +24,19 @@ class Link:
RESULT
=
0
FAIL
=
1
DENIED
=
2
RESULT_START
=
3
RESULT_END
=
4
NOTIFY
=
5
ERROR
=
3
RESULT_START
=
4
RESULT_END
=
5
NOTIFY
=
6
# following cmds are sent by internal methods, thus not visible to outside
__LOCALIZE
=
6
__REGISTER
=
7
__REMOVE
=
8
__CALL
=
9
__CALL_PACKAGE
=
1
0
__ASKNOTIFY
=
1
1
__GETLIST
=
1
2
__CHECKACL
=
1
3
__LOCALIZE
=
7
__REGISTER
=
8
__REMOVE
=
9
__CALL
=
10
__CALL_PACKAGE
=
1
1
__ASKNOTIFY
=
1
2
__GETLIST
=
1
3
__CHECKACL
=
1
4
def
__init__
(
self
,
sockname
=
"/tmp/comar"
):
try
:
...
...
@@ -181,7 +182,7 @@ def test_basic(class_="Time.Clock", package="hwclock", script="../betikler/clock
print
"Reply"
,
reply
if
reply
[
0
]
==
com
.
RESULT
:
break
elif
reply
[
1
]
==
com
.
FAIL
:
elif
reply
[
1
]
==
com
.
ERROR
:
print
"Oops, test failed!"
return
print
"Checking list..."
...
...
@@ -191,7 +192,7 @@ def test_basic(class_="Time.Clock", package="hwclock", script="../betikler/clock
print
"Reply"
,
reply
if
reply
[
0
]
==
com
.
RESULT
:
break
elif
reply
[
1
]
==
com
.
FAIL
:
elif
reply
[
1
]
==
com
.
ERROR
:
print
"Oops, test failed!"
return
print
"Removing the package..."
...
...
@@ -201,7 +202,7 @@ def test_basic(class_="Time.Clock", package="hwclock", script="../betikler/clock
print
"Reply"
,
reply
if
reply
[
0
]
==
com
.
RESULT
:
break
elif
reply
[
1
]
==
com
.
FAIL
:
elif
reply
[
1
]
==
com
.
ERROR
:
print
"Oops, test failed!"
return
print
"Checking list again..."
...
...
@@ -211,7 +212,7 @@ def test_basic(class_="Time.Clock", package="hwclock", script="../betikler/clock
print
"Reply"
,
reply
if
reply
[
0
]
==
com
.
RESULT
:
break
elif
reply
[
1
]
==
com
.
FAIL
:
elif
reply
[
1
]
==
com
.
ERROR
:
print
"Oops, test failed!"
return
print
"Basic functionality is OK :)"
comard/bindings/libcomar.h
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -21,24 +21,26 @@ extern "C" {
#define COMAR_RESULT 0
#define COMAR_FAIL 1
#define COMAR_DENIED 2
#define COMAR_RESULT_START 3
#define COMAR_RESULT_END 4
#define COMAR_NOTIFY 5
#define COMAR_ERROR 3
#define COMAR_RESULT_START 4
#define COMAR_RESULT_END 5
#define COMAR_NOTIFY 6
// commands to the daemon
#define COMAR_LOCALIZE
6
#define COMAR_REGISTER
7
#define COMAR_REMOVE
8
#define COMAR_CALL
9
#define COMAR_CALL_PACKAGE 1
0
#define COMAR_ASKNOTIFY 1
1
#define COMAR_GETLIST 1
2
#define COMAR_CHECKACL 1
3
#define COMAR_LOCALIZE
7
#define COMAR_REGISTER
8
#define COMAR_REMOVE
9
#define COMAR_CALL
10
#define COMAR_CALL_PACKAGE 1
1
#define COMAR_ASKNOTIFY 1
2
#define COMAR_GETLIST 1
3
#define COMAR_CHECKACL 1
4
#define COMAR_CMD_MAX 1
4
#define COMAR_CMD_MAX 1
5
#define COMAR_CMD_NAMES \
"Result", \
"Fail", \
"Denied", \
"Error", \
"ResultStart", \
"ResultEnd", \
"Notify", \
...
...
comard/include/ipc.h
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -12,9 +12,11 @@
// ipc commands
enum
{
CMD_DIED
,
CMD_FAIL
,
CMD_RESULT
,
CMD_RESULT_START
,
CMD_RESULT_END
,
CMD_FAIL
,
CMD_ERROR
,
CMD_REGISTER
,
CMD_REMOVE
,
CMD_CALL
,
...
...
comard/model.xml
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -50,7 +50,7 @@
<method
name=
"deleteHost"
/>
</class>
<class
name=
"Link"
>
<method
name=
"
scan
"
/>
<method
name=
"
getActiveLinks
"
/>
<method
name=
"setAddress"
/>
<method
name=
"getInformation"
/>
<method
name=
"getStatus"
/>
...
...
@@ -64,4 +64,4 @@
</group>
</comarModel>
</comarModel>
\ No newline at end of file
comard/src/csl.c
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -32,6 +32,21 @@ c_call(PyObject *self, PyObject *args)
return
Py_None
;
}
static
PyObject
*
c_fail
(
PyObject
*
self
,
PyObject
*
args
)
{
const
char
*
name
;
size_t
size
;
if
(
!
PyArg_ParseTuple
(
args
,
"s#"
,
&
name
,
&
size
))
return
NULL
;
// FIXME: fail here :)
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
c_notify
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
@@ -48,6 +63,7 @@ c_notify(PyObject *self, PyObject *args)
}
static
PyMethodDef
methods
[]
=
{
{
"fail"
,
c_fail
,
METH_VARARGS
,
"Abort script and return a fail message"
},
{
"call"
,
c_call
,
METH_VARARGS
,
"Call a method from COMAR system model"
},
{
"notify"
,
c_notify
,
METH_VARARGS
,
"Send a notification event"
},
{
NULL
,
NULL
,
0
,
NULL
}
...
...
comard/src/job.c
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -78,13 +78,13 @@ do_register(int node, const char *app, const char *fname)
buf
=
load_file
(
fname
,
NULL
);
if
(
!
buf
)
{
send_result
(
CMD_
FAIL
,
"no file"
,
7
);
send_result
(
CMD_
ERROR
,
"no file"
,
7
);
return
-
1
;
}
e
=
csl_compile
(
buf
,
"test"
,
&
code
,
&
codelen
);
if
(
e
)
{
send_result
(
CMD_
FAIL
,
"compile error"
,
13
);
send_result
(
CMD_
ERROR
,
"compile error"
,
13
);
return
-
1
;
}
...
...
@@ -125,7 +125,7 @@ do_execute(int node, const char *app)
if
(
0
!=
db_get_code
(
model_parent
(
node
),
app
,
&
code
,
&
code_size
))
return
-
1
;
e
=
csl_execute
(
code
,
code_size
,
model_get_method
(
node
),
&
res
,
&
res_size
);
if
(
e
)
{
send_result
(
CMD_
FAIL
,
"err"
,
3
);
send_result
(
CMD_
ERROR
,
"err"
,
3
);
}
else
{
send_result
(
CMD_RESULT
,
res
,
res_size
);
}
...
...
@@ -153,7 +153,7 @@ do_call(int node)
log_debug
(
LOG_JOB
,
"Call(%s)
\n
"
,
model_get_path
(
node
));
if
(
db_get_apps
(
model_parent
(
node
),
&
apps
)
!=
0
)
{
send_result
(
CMD_
FAIL
,
"no app"
,
6
);
send_result
(
CMD_
ERROR
,
"no app"
,
6
);
exit
(
1
);
}
...
...
@@ -168,6 +168,8 @@ do_call(int node)
int
cnt
=
0
;
size_t
size
;
// FIXME: package count, error msg for fork
send_result
(
CMD_RESULT_START
,
NULL
,
0
);
for
(
t
=
apps
;
t
;
t
=
s
)
{
s
=
strchr
(
t
,
'/'
);
if
(
s
)
{
...
...
@@ -186,6 +188,7 @@ do_call(int node)
proc_send
(
TO_PARENT
,
cmd
,
ipc
,
size
);
//--cnt;
}
send_result
(
CMD_RESULT_END
,
NULL
,
0
);
}
free
(
apps
);
...
...
@@ -213,6 +216,10 @@ do_getlist(int node)
if
(
db_get_apps
(
node
,
&
apps
)
!=
0
)
{
send_result
(
CMD_RESULT
,
NULL
,
0
);
}
else
{
char
*
t
;
for
(
t
=
apps
;
*
t
;
t
++
)
{
if
(
*
t
==
'/'
)
*
t
=
' '
;
}
send_result
(
CMD_RESULT
,
apps
,
0
);
}
return
0
;
...
...
comard/src/main.c
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -59,7 +59,10 @@ main(int argc, char *argv[])
break
;
case
CMD_NOTIFY
:
case
CMD_RESULT
:
case
CMD_RESULT_START
:
case
CMD_RESULT_END
:
case
CMD_FAIL
:
case
CMD_ERROR
:
proc_recv
(
p
,
&
ipc
,
size
);
proc_send
(
rpc
,
cmd
,
ipc
,
size
);
free
(
ipc
);
...
...
comard/src/rpc_unix.c
Dosyayı görüntüle @
e1f29f7c
...
...
@@ -25,12 +25,15 @@
/* rpc commands, keep in sync with bindings */
enum
{
// outgoing
RPC_RESULT
=
0
,
RPC_FAIL
,
RPC_DENIED
,
RPC_ERROR
,
RPC_RESULT_START
,
RPC_RESULT_END
,
RPC_NOTIFY
,
// incoming
RPC_LOCALIZE
,
RPC_REGISTER
,
RPC_REMOVE
,
...
...
@@ -335,7 +338,7 @@ pipe_listen(void)
int
sock
,
max
;
tv
.
tv_sec
=
0
;
tv
.
tv_usec
=
50
0000
;
tv
.
tv_usec
=
25
0000
;
FD_ZERO
(
&
fds
);
max
=
0
;
...
...
@@ -391,6 +394,23 @@ pipe_listen(void)
return
0
;
}
void
forward_reply
(
struct
ProcChild
*
p
,
size_t
size
,
int
cmd
)
{
struct
connection
*
c
;
char
*
s
;
size_t
sz
;
ipc_recv
(
p
,
size
);
for
(
c
=
conns
;
c
;
c
=
c
->
next
)
{
if
(
c
==
(
struct
connection
*
)
ipc_get_data
())
{
ipc_get_arg
(
&
s
,
&
sz
);
write_rpc
(
c
,
cmd
,
ipc_get_id
(),
s
,
sz
);
return
;
}
}
}
void
rpc_unix_start
(
void
)
{
...
...
@@ -407,31 +427,37 @@ rpc_unix_start(void)
while
(
1
)
{
while
(
1
==
proc_listen
(
&
p
,
&
cmd
,
&
size
,
0
))
{
if
(
cmd
==
CMD_NOTIFY
)
{
ipc_recv
(
p
,
size
);
for
(
c
=
conns
;
c
;
c
=
c
->
next
)
{
int
no
=
ipc_get_node
();
if
(
notify_is_marked
(
c
->
notify_mask
,
no
))
{
// FIXME: return argument too
const
char
*
name
=
model_get_path
(
no
);
write_rpc
(
c
,
RPC_NOTIFY
,
0
,
name
,
strlen
(
name
));
switch
(
cmd
)
{
case
CMD_NOTIFY
:
ipc_recv
(
p
,
size
);
for
(
c
=
conns
;
c
;
c
=
c
->
next
)
{
int
no
=
ipc_get_node
();
if
(
notify_is_marked
(
c
->
notify_mask
,
no
))
{
// FIXME: return argument too
const
char
*
name
=
model_get_path
(
no
);
write_rpc
(
c
,
RPC_NOTIFY
,
0
,
name
,
strlen
(
name
));
}
}
}
continue
;
}
else
if
(
cmd
!=
CMD_RESULT
&&
cmd
!=
CMD_FAIL
)
continue
;
ipc_recv
(
p
,
size
);
for
(
c
=
conns
;
c
;
c
=
c
->
next
)
{
if
(
c
==
(
struct
connection
*
)
ipc_get_data
())
{
char
*
s
;
size_t
sz
;
ipc_get_arg
(
&
s
,
&
sz
);
if
(
cmd
==
CMD_RESULT
)
cmd
=
RPC_RESULT
;
else
cmd
=
RPC_FAIL
;
write_rpc
(
c
,
cmd
,
ipc_get_id
(),
s
,
sz
);
continue
;
case
CMD_RESULT_START
:
forward_reply
(
p
,
size
,
RPC_RESULT_START
);
break
;
}
case
CMD_RESULT_END
:
forward_reply
(
p
,
size
,
RPC_RESULT_END
);
break
;
case
CMD_RESULT
:
forward_reply
(
p
,
size
,
RPC_RESULT
);
break
;
case
CMD_FAIL
:
forward_reply
(
p
,
size
,
RPC_FAIL
);
break
;
case
CMD_ERROR
:
forward_reply
(
p
,
size
,
RPC_ERROR
);
break
;
default:
// this shouldn't happen, warn and skip
log_error
(
"RPC: Unexpected internal command %d
\n
"
,
cmd
);
ipc_recv
(
p
,
size
);
}
}
pipe_listen
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment